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;
作者: 清澈Saup
出处:http://www.cnblogs.com/qingche/
本文版权归作者和博客园共有,欢迎转载,但必须保留此段声明,且在文章页面明显位置给出原文连接。
最新文章
- Atitit.报名模块的管理
- css中左侧固定,右侧自适应
- PG, Pool之间的一些数量关系
- Maven学习小结(七 生命周期[转])
- hbase安装(zookeeper等)
- #Leet Code# Best Time to Buy and Sell Stock
- _OBJC_CLASS_$_ errors 错误解决办法
- 【HDU】病毒侵袭持续中(AC自己主动机+map)
- postgresql 修改属性
- Kafka系列之-Kafka Protocol实例分析
- AI 生成式对抗网络(GAN)
- Tomcat服务器为java项目配置顶级域名
- Oracle DB
- springdata笔记2
- __getitem__ __setitem__ __delitem__ 使用
- pycharm技巧
- 最近无意中看到一个讲解spring mvc的系列,从源码的角度讲解,特记录下来,供以后反复学习
- Java.lang.Character类
- spring-mvc实现模拟数据到网页展示过程代码
- AD域创建用户无法登录
热门文章
- PHP中使用foreach时加&;符号的用法
- git 之忽略文件 gitignore 创建和使用规则
- python教程(二)&#183;数据类型
- Java学习笔记二十七:Java中的抽象类
- burp实时获取token
- jetson tx2 安装tensorflow
- python的第一个程序“Hello,World”,传闻要想学好新语言....
- pix2code开发笔记
- myeclipse 配置堆内存
- 两个有序数组合并成一个有序数组(要求时间复杂度为O(n))