知识点总结1

1.获得项目中info.plist文件的内容
1> [NSBundle mainBundle].infoDictionary
2> 版本号在info.plist中的key:kCFBundleVersionKey

2.自定义控制器的view
重写loadView方法(不需要调用[super loadView])

3.控制器view的高度和状态栏的关系
创建控制器的view时,系统会检测状态栏是否显示
* 如果有状态栏,那么控制器view的高度是460(iPhone5中是548)
* 如果没有状态栏,那么控制器view的高度是480(iPhone5中是568)

4.按钮的状态
UIControlStateNormal 普通(默认的状态)
UIControlStateHighlighted 高亮(用户长按的时候)
UIControlStateDisabled 失效(通过代码控制:enabled属性)
UIControlStateSelected 选中(通过代码控制:selected属性)

5.错误调试技巧
1> 一个控件无法显示出来的可能原因
* 没有设置宽高
* 位置设置不对
* 没有被addSubview到屏幕上

2> 一个控件无法跟用户交互的可能原因
* (父控件的)userInteractionEnabled = NO;
* (父控件的)hidden = YES
* (父控件的)alpha <= 0.01
* (父控件的)背景是clearColor

6.按钮的设置
1> 文字设置
// 居中
self.titleLabel.textAlignment = NSTextAlignmentCenter;

// 设置文字的位置:重写titleRectForContentRect:方法
- (CGRect)titleRectForContentRect:(CGRect)contentRect

2> 图片设置
// 图片按照原比例显示(不拉伸)
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
// 高亮状态下不更改图片的颜色
self.adjustsImageWhenHighlighted = NO;

// 设置图片的位置:重写imageRectForContentRect:方法
- (CGRect)imageRectForContentRect:(CGRect)contentRect

3> 覆盖父类在高亮时所作的行为(此方法比较重要)
// 重写setHighlighted:方法
- (void)setHighlighted:(BOOL)highlighted {}

原文地址:https://www.cnblogs.com/yyh123/p/3375148.html