1、UIView图片显示格式调整
UIImageView *icon = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kViewW, 50)];
icon.image = [UIImage imageNamed:self.array[i][@"icon"]];
icon.contentMode = UIViewContentModeScaleAspectFit;
[self.appview addSubview:icon];
通过UIViewContentMode进行图片显示格式调整
2、获取最大位置坐标
#define kViewW 80
// 设置视图1
UIImageView icon = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kViewW, 60)];
[self.appview addSubview:icon];
// 设置与视图1相连接的视图
UILabel *desc = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(icon.frame), kViewW, 15)];
desc.backgroundColor = [UIColor greenColor];
[self.appview addSubview:desc];
CGRectGetMaxX/CGRectGetMaxY可以读取相应视图占有最大的坐标位置
3、调整状态栏颜色
/**
UIStatusBarStyleDefault 黑色状态栏
UIStatusBarStyleLightContent 亮色状态栏
*/
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
4、子视图前置
//bringSubviewToFront将子视图前置
[self.view bringSubviewToFront:self.iconButton];
5、查询或补齐系统代码可使用esc
6、命名约定
- 所有方法首字母小写
- 当单词切换时,单词首字母为大写(驼峰法)
- 类名要大写
7、instancetype用法
- instancetype会让编译器检查实例化对象的准确类型
- instancetype只能用于返回类型,不能当做参数使用
- (instancetype)initWithDict:(NSDictionary *)dict;
- (instancetype)appInfoWithDict:(NSDictionary *)dict;
8、readonly属性使用注意
- @property中readonly表示不允许修改对象的指针地址,但是可以修改对象的属性。
- 通常使用@property关键字定义属性时,会生成getter&setter方法,还会生成一个带下划线的成员变量。
- 如果是readonly属性,只会生成getter方法,不会生成带下划线的成员变量.