iOS笔记1
2015-11-30 19:34
375 查看
1
//UILabel属性
@property(nonatomic) NSTextAlignm
4000
ent textAlignment;
//对齐模式(比如左对齐、居中对齐、右对齐)
@property(nonatomic) NSInteger numberOfLines;
//文字行数
@property(nonatomic) NSLineBreakMode lineBreakMode;
//换行模式
2
//UIFont
UIFont代表字体,常见创建方法有以下几个:
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize; 系统默认字体
+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize; 粗体
+ (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize; 斜体
3
//UIImageView
//UIImageView的常见属性
@property(nonatomic,retain) UIImage *image;
显示的图片
@property(nonatomic,copy) NSArray *animationImages;
显示的动画图片
@property(nonatomic) NSTimeInterval animationDuration;
动画图片的持续时间
@property(nonatomic) NSInteger animationRepeatCount;
动画的播放次数(默认是0,代表无限播放)
//UIImageView的常见方法
- (void)startAnimating; // 开始动画
- (void)stopAnimating; // 停止动画
- (BOOL)isAnimating; // 是否正在执行动画
4
//UIButton
//UIButton的常见设置
设置按钮的文字字体(需要拿到按钮内部的label来设置)
btn.titleLabel.font = [UIFont systemFontOfSize:13];
(NSString *)titleForState:(UIControlState)state;
获得按钮的文字
(UIColor *)titleColorForState:(UIControlState)state;
获得按钮的文字颜色
(UIImage *)imageForState:(UIControlState)state;
获得按钮内部的小图片
(UIImage *)backgroundImageForState:(UIControlState)state;
获得按钮的背景图片
5
//解析Plist文件
接下来通过代码来解析Plist文件中的数据
获得Plist文件的全路径
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:@”shops” ofType:@”plist”];
加载plist文件
_shops = [NSArray arrayWithContentsOfFile:path];
6
//Xib的加载
方法1
NSArray *views = [[NSBundle mainBundle] loadNibNamed:@”xib文件名” owner:nil options:nil]
方法2
UINib *nib = [UINib nibWithNibName:@”xib文件名” bundle:nil];
NSArray *views = [nib instantiateWithOwner:nil options:nil];
7
//判断sender的类型是否匹配
if ([sender isKindOfClass:[UIButton class]])
8
loadNibNamed:NSStringFromclass(……)
9
//加载View 会调用的方法(分代码方法、nib加载)
在通过nib 加载view的话, 那么只会调用 initWithCoder awakeFromNib
通过代码的方法我们必须使用 initWithFrame 那么就会调用 init/initWithFrame
10
//超出父控件就会自动去掉
view.clipsToBounds = YES;
11
//lable控件要可以设置背景色带透明的(RGB),不影响文字的显示
//UILabel属性
@property(nonatomic) NSTextAlignm
4000
ent textAlignment;
//对齐模式(比如左对齐、居中对齐、右对齐)
@property(nonatomic) NSInteger numberOfLines;
//文字行数
@property(nonatomic) NSLineBreakMode lineBreakMode;
//换行模式
2
//UIFont
UIFont代表字体,常见创建方法有以下几个:
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize; 系统默认字体
+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize; 粗体
+ (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize; 斜体
3
//UIImageView
//UIImageView的常见属性
@property(nonatomic,retain) UIImage *image;
显示的图片
@property(nonatomic,copy) NSArray *animationImages;
显示的动画图片
@property(nonatomic) NSTimeInterval animationDuration;
动画图片的持续时间
@property(nonatomic) NSInteger animationRepeatCount;
动画的播放次数(默认是0,代表无限播放)
//UIImageView的常见方法
- (void)startAnimating; // 开始动画
- (void)stopAnimating; // 停止动画
- (BOOL)isAnimating; // 是否正在执行动画
4
//UIButton
//UIButton的常见设置
设置按钮的文字字体(需要拿到按钮内部的label来设置)
btn.titleLabel.font = [UIFont systemFontOfSize:13];
(NSString *)titleForState:(UIControlState)state;
获得按钮的文字
(UIColor *)titleColorForState:(UIControlState)state;
获得按钮的文字颜色
(UIImage *)imageForState:(UIControlState)state;
获得按钮内部的小图片
(UIImage *)backgroundImageForState:(UIControlState)state;
获得按钮的背景图片
5
//解析Plist文件
接下来通过代码来解析Plist文件中的数据
获得Plist文件的全路径
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:@”shops” ofType:@”plist”];
加载plist文件
_shops = [NSArray arrayWithContentsOfFile:path];
6
//Xib的加载
方法1
NSArray *views = [[NSBundle mainBundle] loadNibNamed:@”xib文件名” owner:nil options:nil]
方法2
UINib *nib = [UINib nibWithNibName:@”xib文件名” bundle:nil];
NSArray *views = [nib instantiateWithOwner:nil options:nil];
7
//判断sender的类型是否匹配
if ([sender isKindOfClass:[UIButton class]])
8
loadNibNamed:NSStringFromclass(……)
9
//加载View 会调用的方法(分代码方法、nib加载)
在通过nib 加载view的话, 那么只会调用 initWithCoder awakeFromNib
通过代码的方法我们必须使用 initWithFrame 那么就会调用 init/initWithFrame
10
//超出父控件就会自动去掉
view.clipsToBounds = YES;
11
//lable控件要可以设置背景色带透明的(RGB),不影响文字的显示
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 讲解iOS开发中基本的定位功能实现
- js判断客户端是iOS还是Android等移动终端的方法
- IOS开发环境windows化攻略
- 浅析iOS应用开发中线程间的通信与线程安全问题
- 检测iOS设备是否越狱的方法
- .net平台推送ios消息的实现方法
- 探讨Android与iOS,我们将何去何从?
- Android、iOS和Windows Phone中的推送技术详解
- IOS 改变键盘颜色代码
- 举例详解iOS开发过程中的沙盒机制与文件
- Android和IOS的浏览器中检测是否安装某个客户端的方法
- 分享一个iOS下实现基本绘画板功能的简单方法
- javascript实现阻止iOS APP中的链接打开Safari浏览器