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,也是比較特殊一點。
不知道是否對大家有用。