UI基础学习04
来源:互联网 发布:地震能被预测吗 知乎 编辑:程序博客网 时间:2024/05/22 06:12
内边距
Ios 7 开始状态栏都由控制器管理
// 控制状态栏的样式 重写父类方法
- (UIStatusBarStyle)preferredStatusBarStyle
{
// 白色 黑色UIStatusBarStyleDefault
return UIStatusBarStyleLightContent;
}
不可用的时候不要调整图片
按钮不可用
用户交互事件
更改名字
当你一个按钮从其他按钮拷贝过来的时候,一定要把上一个按钮的点击事件给清掉
屏幕分辨率:不同分辨率(尺寸)的屏幕适配不同像素的图片
3gs 1个点1个像素4- 6 1个点2个像素
6p 1个点3个像素
图片的命名:@1x @2x @3x
加载plist文件 字典转模型
- (NSArray *)apps
{
if(_apps == nil)
{
NSString * path = [[NSBundle mainBundle] pathForResource:@"app.plist" ofType:nil];
NSArray * dictArray = [NSArray arrayWithContentsOfFile:path];
// 将dictArray里面的所有字典转成模型对象,放到新的数组中
NSMutableArray * appArray = [NSMutableArray array];
for (NSDictionary * dict in dictArray) {
// 创建一个模型对象
MJApp * app = [[MJApp alloc] initWithDict:dict];
//
// // 将字典的所有属性赋值给模型
// app.name = dict[@"name"];
// app.icon = dict[@"icon"];
// 添加模型对象到数组中
[appArray addObject:app];
}
// 赋值
_apps = appArray;
}
return _apps;
}
xib 文件的加载
// 创建View
NSBundle * bundle = [NSBundle mainBundle];
// 读取xib文件(会创建xib中描述的所有对象,并钱按顺序放到数组中返回)
NSArray * objs = [bundle loadNibNamed:@"MJAppView" owner:nil options:nil];
UIView * appView = [objs lastObject];
// 添加View
[self.view addSubview:appView];
// 设置数据
MJApp * app = self.apps[i];
// 图片
// UIImageView * iconView = appView.subviews[0];
UIImageView * iconView = (UIImageView *)[appView viewWithTag:10];
iconView.image = [UIImage imageNamed:app.icon];
// 名称
// UILabel * nameLabel = appView.subviews[1];
UILabel * nameLabel = (UILabel *)[appView viewWithTag:20];
nameLabel.text = app.name;
// 代码监听按钮点击
[cover addTarget:self action:@selector(smallImg) forControlEvents:UIControlEventTouchUpInside];
// 方法 更换子控件的位置 把iconBtn放在最前面
[self.view bringSubviewToFront:self.iconBtn];
// 删除控件 要删除哪个控件,就用这个控件的删除方法
[self.cover removeFromSuperview];
动画的2种方式 头尾式 block式
// [UIView setAnimationDelegate:self]; 代理,动画结束用self调用removeCover方法
// [UIView setAnimationDidStopSelector:@selector(removeCover)];
高亮的时候会自动调整灰色
自定义声明一个协议
协议方法
- UI基础学习04
- UIScrollView 基础学习 - UI
- UI基础学习01
- UI基础学习02
- UI基础学习03
- UI基础学习05
- UI基础学习05
- UI基础学习06
- UI基础学习07
- UI基础学习08
- jQuery UI基础 学习笔记
- JSPatch学习系列-UI基础
- UI基础学习第一天
- iOS UI基础学习历程
- iOS UI基础学习 Note_dayOne
- iOS UI基础学习 Note_dayTwo
- iOS UI基础学习 Note_dayThree
- iOS UI基础学习 Note_dayFour
- bat---按编号批量重命名指定格式文件
- 素数和sqrt函数
- 【转载】Java虚拟机的内存组成以及堆内存介绍
- Android自定义CheckBox CheckGroup超好用
- 2016多校联赛 hdu5826 physics 数学题
- UI基础学习04
- Java三大内存区域
- Spring AOP 基础(二)
- Jsoup爬数据+设置代理IP
- 英式英语 vs 美式英语
- POJ 2739
- [2016ACM多校] HDU5829 卷积 NTT
- Markdown编辑器对比分析
- linux多线程编程详解