UITextView不可编辑,将UITextView中的editable属性设为NO。
UIButton 不可点击,将UIButton 中的enable属性设为NO。
UITextField 不可编辑, 将UITextField中的enable属性设为NO。
UITextField的输入提示将提示信息赋给placeholder属性中。
自定义一种颜色
- UIColor *myColor = UIColor coloWithRed:0.8 green:0.3 blue:0.6 alpha:1];
通过RGB来配一种颜色。RGB的参数为0.0到1.0之间的float型的数据。
可以将空间对象设置一个Tag相当于android中的ID来标示唯一的一个对象。
如:
- UITextField *verifyPasswordText = [[UITextField alloc] initWithFrame:CGRectMake(HC_Login_LabelWidth+10, 10+1*(HC_Login_LabelHeight+HC_Login_LabelSpace), 1.5*HC_Login_LabelWidth, 0.15*200)];
- verifyPasswordText.tag = 1003;
- verifyPasswordText.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
- verifyPasswordText.placeholder = MORE_ENTERPASSWORDAGAIN;
- verifyPasswordText.returnKeyType = UIReturnKeyDone;
- verifyPasswordText.secureTextEntry = YES;
- [verifyPasswordText addTarget:self action:@selector(textFieldDoneEditing:) forControlEvents:UIControlEventEditingDidEndOnExit];
- verifyPasswordText.borderStyle = UITextBorderStyleRoundedRect;
- verifyPasswordText.enabled = NO;
- verifyPasswordField = verifyPasswordText;
- [self.setPassword addSubview:verifyPasswordText];
- [verifyPasswordText release];
- UITextField *verifyWordTextField2 = (UITextField *)[self.view viewWithTag:1003];
可以通过viewWithTag这个函数来将该控件的对象赋值给另一个对象。
NSNotificationCenter 的使用
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(changeTheme:)
- name:ThemeFlag object:nil];
其中changeTheme是一个方法名:
- - (void)changeTheme:(NSNotification *)notification
- {
- NSString *themeName = [MessageCenter shareInstance].themeSetName;
- NSDictionary *array = (NSDictionary *)[[DataCenter shareInstance] getTheme:themeName];
- if ([themeName isEqualToString:@"默认"]) {
- UIImage *icon = [array objectForKey:@"navBg"];
- self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
- self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:1];
- self.navigationController.navigationBar.layer.contents = (id)icon.CGImage;
- }
- if ([themeName isEqualToString:@"绚黑"]) {
- UIImage *icon = [array objectForKey:@"navBg"];
- self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
- self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.75 green:0 blue:0 alpha:1];
- self.navigationController.navigationBar.layer.contents = (id)icon.CGImage;
- }
- }
发送改变主题的消息
- //发送切换主题消息
- switch (indexPath.row)
- {
- case 0:
- {
- [[MessageCenter shareInstance].settingDic setObject:@"0" forKey:@"setTheme"];
- [MessageCenter NotificationCenterToChat:ThemeFlag userInfo:nil];
- NSDictionary *array = (NSDictionary *)[[DataCenter shareInstance] getTheme:ILIAO_THEME_PERMIT];
- if ([array count] > 0)
- {
- UIImage *icon = [array objectForKey:@"navBg"];
- self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
- self.navigationController.navigationBar.tintColor = [UIColor colorWithHexString:@"#003892"];
- self.navigationController.navigationBar.layer.contents = (id)icon.CGImage;
- //tableView.backgroundColor = [UIColor darkGrayColor];
- //tableView.separatorColor = [UIColor grayColor];
- }
- [self saveSettingPlist:[MessageCenter shareInstance].settingDic];
- break;
- }
- case 1:
- {
- [[MessageCenter shareInstance].settingDic setObject:@"1" forKey:@"setTheme"];
- [MessageCenter NotificationCenterToChat:ThemeFlag userInfo:nil];
- NSDictionary *array = (NSDictionary *)[[DataCenter shareInstance] getTheme:ILIAO_THEME_BRIGHT_BLACK];
- if ([array count] > 0)
- {
- UIImage *icon = [array objectForKey:@"navBg"];
- self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
- self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.75 green:0 blue:0 alpha:1];
- self.navigationController.navigationBar.layer.contents = (id)icon.CGImage;
- //self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
- //tableView.backgroundColor = [UIColor darkGrayColor];
- //tableView.separatorColor = [UIColor grayColor];
- }
- [self saveSettingPlist:[MessageCenter shareInstance].settingDic];
- break;
- }
- default:
- break;
- }
零零散散的写了一些在项目中遇到一些常用的UI,也是比较特殊一点。