1. 自定义导航条的标题(文字大小和颜色)
直接上代码
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
titleLabel.textColor = [UIColor blackColor];
titleLabel.font = [UIFont systemFontOfSize:17];
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.text=@"登录";
self.navigationItem.titleView = titleLabel;
2. 设置textField的左边图片
直接上代码
self.textFiled.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_login_shouji"]];
self.textFiled.leftViewMode = UITextFieldViewModeAlways;
3. 设置textfield的placeholder颜色
直接上代码
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.loginInputId.placeholder attributes:@{NSForegroundColorAttributeName: color}];
4. 判断输入法是否是中文
怒上代码 中文是zh-cn,应为是en-us,其他地区见
地区代码
BOOL isChinese = [[[UIApplication sharedApplication] textInputMode].primaryLanguage isEqualToString:@"zh-cn"];
5. fullResolutionImage 与fullScreenImage
参考自使用ALAssetsLibrary读取所有照片
ALAssetRepresentation的 metadata 方法很慢,我在iPhone4 iOS5.1.1中测试,此方法返回需要40-50ms,所以获取图片的个各种属性尽量直接从ALAssetRepresentation中获取,不要读取metadata,调用多次也确实很容易会memory warning,系统”相册”程序显示的图片是 fullScreenImage ,而不是 fullResolutionImage ,fullResolutionImage尺寸太大,在手机端显示推荐用fullScreenImage。
fullScreenImage已被调整过方向,可直接使用,即
[UIImage imageWithCGImage:representation.fullScreenImage];
使用fullResolutionImage要自己调整方法和scale,即
[UIImage imageWithCGImage:representation.fullResolutionImage scale:representation.scale orientation:representation.orientation];