iOS常见控件设置
2015-10-18 13:06
357 查看
UIView常见属性
1.frame 位置和尺寸(以父控件的左上角为原点(0,0)) 2.center 中点 (以父控件的左上角为原点(0,0)) 3.bounds 位置和尺寸(以自己的左上角为原点 (0,0)) 4.transform 形变属性(缩放,旋转) 5.backgroundColor 背景颜色 6.tag 标识(父控件可以根据这个标识找到对应的子控件,同一个父控件中的子控件不要一样) 7. hidden 设置是否要隐藏 8.alpha 透明度(0~1); 9.opaque 不透明度(0~1); 10.userInteractionEnabled 能否跟用户进行交互(YES 能交互) 11.superView 父控件 12.subviews 子控件 13.contentMode 内容显示的模式 拉伸自适应
UIView常见方法
1.addSubview 添加子控件,被添加到最上面(subviews中的最后面) 2.removeFromSuperview 从父控件中移除 3.viewWithTag: 父控件可以根据这个tag 标识找到对应的控件(遍历所有的子控件) 4.insertSubview:atIndex: 添加子控件到指定的位置 5.利用两个类方法来执行动画的两个方法 +(void) beginAnimations:(NSString *)animationID context:(void *)context; /**..需要执行动画的代码..**/ +(void) commitAnimations; 6.利用blok 执行动画 /* duration 动画持续时间 animations 存放需林执行动画的代码 completion 存放动画完毕后需要执行的操作代码 */ + (void) animateWithDuration:(NSTimeInterval) duration animations:(void (^)(void))animations completion:(void(^)) (BOOL finished) completion
[b]UILabel常见属性:[/b]
@property(nonatomic,copy) NSString *text; 显示的文字 @property(nonatomic,retain) UIFont *font; 字体 @property(nonatomic,retain) UIColor *textColor; 文字颜色 @property(nonatomic) NSTextAlignment textAlignment; 对齐模式(比如左对齐、居中对齐、右对齐)
UIFont常见创建方法:
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize; 系统默认字体 + (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize; 粗体 + (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize; 斜体
UIButton常见设置
- (void)setTitle:(NSString *)title forState:(UIControlState)state; 设置按钮的文字 - (void)setTitleColor:(UIColor *)color forState:(UIControlState)state; 设置按钮的文字颜色 - (void)setImage:(UIImage *)image forState:(UIControlState)state; 设置按钮内部的小图片 - (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state; 设置按钮的背景图片 设置按钮的文字字体(需要拿到按钮内部的label来设置) btn.titleLabel.font = [UIFont systemFontOfSize:13];
以后会陆续补上。。。。。。。
相关文章推荐