您的位置:首页 > 移动开发 > IOS开发

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),不影响文字的显示
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios