iOS-UI控件常见属性总结

1.UIView
// 如果userInteractionEnabled=NO,不能跟用户交互
@property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled;
// 控件的标记(父控件通过标记可以找到对应的子控件)
@property(nonatomic) NSInteger tag;
// 控件的位置和尺寸(以父控件的左上角为坐标原点)
@property(nonatomic) CGRect            frame;
// 控件的位置和尺寸(以控件本身的左上角为坐标原点)
@property(nonatomic) CGRect            bounds;
// 控件的中点位置(以父控件的左上角为坐标原点)
@property(nonatomic) CGPoint           center;
// 形变属性:旋转、缩放、平移
@property(nonatomic) CGAffineTransform transform;
// 父控件
@property(nonatomic,readonly) UIView       *superview;
// 所有的子控件
@property(nonatomic,readonly,copy) NSArray *subviews;

2.UILabel
// 显示的文字
@property(nonatomic,copy)   NSString           *text;
// 字体
@property(nonatomic,retain) UIFont             *font;
// 文字颜色
@property(nonatomic,retain) UIColor            *textColor;
// 文字的排列方式(左对齐、居中、右对齐)
@property(nonatomic)        NSTextAlignment    textAlignment;
// 设置行数(行数==0代表自动换行)
@property(nonatomic) NSInteger numberOfLines;

3.UIImageView
// 显示的图片
@property(nonatomic,retain) UIImage *image;
// 设置序列帧图片数组(按顺序播放animationImages数组中的图片)
@property(nonatomic,copy) NSArray *animationImages;
// 序列帧动画的持续时间
@property(nonatomic) NSTimeInterval animationDuration;
// 序列帧动画的执行字数(默认是0,代表无限循环)
@property(nonatomic) NSInteger      animationRepeatCount;

4.UIScrollView
// 表示UIScrollView所滚动的位置
@property(nonatomic) CGPoint contentOffset;
// 表示UIScrollView的内容尺寸(能滚动的范围)
@property(nonatomic)         CGSize                       contentSize;
// 增加UIScrollView额外的边缘滚动区域
@property(nonatomic)         UIEdgeInsets                 contentInset;
// 代理
@property(nonatomic,assign) id<UIScrollViewDelegate>      delegate;

5.UITableView

6.UIPickerView

7.UIControl
// 是否可用
@property(nonatomic,getter=isEnabled) BOOL enabled;
// 自动拥有很多种状态
// 可以通过下面的方法来监听控件内部的一些事件:点击、值改变
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;

1> UIDatePicker
// 设置模式(类型)
@property(nonatomic) UIDatePickerMode datePickerMode;   
// 设置区域(zh_CN代表天朝)
@property(nonatomic,retain) NSLocale      *locale;
// 设置当前时间
@property(nonatomic,retain) NSDate        *date;

// UIDatePicker内部显示的日期更改了,就会触发值改变事件

2> UISwitch
// 控制开关状态
@property(nonatomic,getter=isOn) BOOL on;
- (void)setOn:(BOOL)on animated:(BOOL)animated;

// UISwitch内部开关状态更改了,就会触发值改变事件

3> UISegmentControl
// 一共有多少块区域
@property(nonatomic,readonly) NSUInteger numberOfSegments;
// 当前选中区域的位置
@property(nonatomic) NSInteger selectedSegmentIndex;
// UISegmentControl内部选中的区域更改了,就会触发值改变事件

4> UISlider
// 设置当前的进度值
@property(nonatomic) float value;
// 设置最小的进度值
@property(nonatomic) float minimumValue;
// 设置最大的进度值
@property(nonatomic) float maximumValue;

// UISlider内部的进度值更改了,就会触发值改变事件

5> UIButton
// 快速创建一个按钮
+ (id)buttonWithType:(UIButtonType)buttonType;
// 设置按钮的内边距
@property(nonatomic) UIEdgeInsets contentEdgeInsets;
// 按钮内部的标签控件
@property(nonatomic,readonly,retain) UILabel     *titleLabel;
// 按钮内部的图片控件
@property(nonatomic,readonly,retain) UIImageView *imageView;

// 设置内部titleLabel显示的文字
- (void)setTitle:(NSString *)title forState:(UIControlState)state;
// 设置内部titleLabel的文字颜色
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state;
// 设置内部imageView显示的图片
- (void)setImage:(UIImage *)image forState:(UIControlState)state;
// 设置背景图片
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state;

- (NSString *)titleForState:(UIControlState)state;
- (UIColor *)titleColorForState:(UIControlState)state;
- (UIImage *)imageForState:(UIControlState)state;
- (UIImage *)backgroundImageForState:(UIControlState)state;

6> UITextField(通过delegate监听内部的事件)

8.UIAlertView
// 创建一个UIAlertView对话框
/*
 title : 对话框标题
 message : 对话框中间显示的文字内容
 cancelButtonTitle : 取消按钮的文字
 otherButtonTitles : 其他按钮的文字(设置多个)
 delegate : 用来监听alertView上面按钮的点击
 */
- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id /*<UIAlertViewDelegate>*/)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;

// 显示
- (void)show;

posted @ 2014-04-15 19:35  Liberal.C  阅读(378)  评论(0编辑  收藏  举报