首页 > 移动平台 > 详细

iOS常见控件设置

时间:2015-10-18 16:58:57      阅读:291      评论:0      收藏:0      [点我收藏+]

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




UILabel常见属性:

@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];


  以后会陆续补上。。。。。。。

版权声明:本文为博主原创文章,未经博主允许不得转载。

iOS常见控件设置

原文:http://blog.csdn.net/zhixinhuacom/article/details/49227119

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!