代码拉取完成,页面将自动刷新
//
// NotificationViewController.m
// MyAllDemo
//
// Created by mac on 14-10-14.
// Copyright (c) 2014年 huacheng. All rights reserved.
//
#import "NotificationViewController.h"
#import "SendNotificationViewController.h"
@interface NotificationViewController ()
@end
@implementation NotificationViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIButton *button1=[[UIButton alloc] initWithFrame:CGRectMake(110, 100, 100, 30)];
[button1 setTitle:@"红色" forState:UIControlStateNormal];
button1.backgroundColor=[UIColor redColor];
[button1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button1 addTarget:self action:@selector(redChange) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button1];
//注册通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doChange:) name:@"notificationName" object:nil];
}
- (void)redChange
{
SendNotificationViewController *next = [[SendNotificationViewController alloc] init];
[self.navigationController pushViewController:next animated:YES];
// //发送通知
// NSDictionary *dict=[NSDictionary dictionaryWithObject:@"redcolor" forKey:@"color"];
// [[NSNotificationCenter defaultCenter] postNotificationName:@"notificationName" object:self userInfo:dict];
}
- (void)yellowChange
{
// //发送通知
// NSDictionary *dict1=[NSDictionary dictionaryWithObject:@"yellowcolor" forKey:@"color"];
// [[NSNotificationCenter defaultCenter] postNotificationName:@"notificationName" object:self userInfo:dict1];
}
- (void)doChange:(NSNotification *)notification
{
NSDictionary *dict2=[notification userInfo];
NSString *colorstr=[dict2 objectForKey:@"color"];
UIColor *color=nil;
if ([colorstr isEqualToString:@"redcolor"])
{
color=[UIColor redColor];
}
if([colorstr isEqualToString:@"yellowcolor"])
{
color=[UIColor yellowColor];
}
self.view.backgroundColor=color;
}
- (void)btnClick
{
// ChangeColorViewController *chage=[[ChangeColorViewController alloc] initWithNibName:@"ChangeColorViewController" bundle:nil];
}
@end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。