·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> app软件开发 >> IOS开发 >> UI控件的常见属性

UI控件的常见属性

作者:佚名      IOS开发编辑:admin      更新时间:2022-07-23

UIView的常见属性:

//获得自己的父控件对象
@PRoperty(nonatomic,readonly) UIView *superview;

//获得自己的所有子控件对象
@property(nonatomic,readonly,copy) NSArray *subviews;

//控件的ID\标识,父控件可以通过tag来找到对应的子控件
@property(nonatomic) NSInteger tag;

//控件的形变属性(可以设置旋转角度、比例缩放、平移等属性
@property(nonatomic) CGAffineTransform transform;
//控件所在矩形框在父控件中的位置和尺寸(以父控件的左上角为坐标原点)
@property(nonatomic) CGRect frame;

//控件所在矩形框的位置和尺寸(以自己左上角为坐标原点,所以bounds的x\y一般为0)
@property(nonatomic) CGRect bounds;

//控件中点的位置(以父控件的左上角为坐标原点)
@property(nonatomic) CGPoint center;
•在UIKit中,坐标系的原点(0,0)在左上角,x值向右正向延伸,y值向下正向延伸

UILabel的常见属性:

//label显示的文字
@property(nonatomic,copy)   NSString *text;

//文字字体大小
@property(nonatomic,retain) UIFont *font;

//文字的颜色
@property(nonatomic,retain) UIColor *textColor;

//文字的排列方式(左对齐、居中、右对齐)枚举值
@property(nonatomic)NSTextAlignment textAlignment;

// 设置行数(行数==0代表自动换行)
@property(nonatomic) NSInteger numberOfLines;

UIImageView的常见属性:

// 所要显示的图片
@property(nonatomic,retain) UIImage *image;

// 设置序列帧动画数组(按顺序播放animationImages数组中的图片)
@property(nonatomic,copy) NSArray *animationImages;

// 序列帧动画的持续时间
@property(nonatomic) NSTimeInterval animationDuration;

// 序列帧动画的执行次数(默认是0,代表无限循环)
@property(nonatomic) NSInteger animationRepeatCount;

UIScrollView的常见属性:

// 表示UIScrollView所滚动的位置
@property(nonatomic) CGPoint contentOffset;

// 表示UIScrollView的内容尺寸(能滚动的范围)
@property(nonatomic) CGSize contentSize;

// 增加UIScrollView额外的边缘滚动区域
@property(nonatomic)UIEdgeInsets contentInset;

// 代理
@property(nonatomic,assign) id<UIScrollViewDelegate>delegate;

下图介绍了UIScrollView的几个常见属性

 

 

待续................................