iOS常用小控件集合


【UISlider】<已讲>
//一个滑块控件,高度固定(约35)

//滑块的值
@property(nonatomic) float value;
//设置滑块的最小值(默认最小和最大分别是0.0和1.0)
@property(nonatomic) float minimumValue;
//设置滑块的最大值
@property(nonatomic) float maximumValue;
//滑动时是否触发事件(默认是yes)
@property(nonatomic,getter=isContinuous) BOOL continuous;

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
//最后一个参数写UIControlEventValueChanged,监控滑动状态
//滑动时触发,如果continuous设为no的话就滑动结束时触发,打印slider.value


【UISegmentedControl】
//分段选取器

//初始化传递进去的NSArray可以用字符串或图片
- (id)initWithItems:(NSArray *)items;
//设置frame

//设置风格样式(ios7中被禁用了)
@property(nonatomic) UISegmentedControlStyle segmentedControlStyle;
//设置哪个分段处于选中状态,不设置此属性,任何分段都处于非选中状态
@property(nonatomic) NSInteger selectedSegmentIndex;

//插入和删除某个分段
- (void)insertSegmentWithTitle:(NSString *)title atIndex:(NSUInteger)segment animated:(BOOL)animated;
- (void)removeSegmentAtIndex:(NSUInteger)segment animated:(BOOL)animated;
//删除所有分段,相当于把这个选取器给删了。。。
- (void)removeAllSegments;

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
//最后一个参数写UIControlEventValueChanged,监控点击状态
//点击时触发

//打印
//根据分段的下标,拿到分段的标题
- (NSString *)titleForSegmentAtIndex:(NSUInteger)segment;

*****************************************
【UISwitch】
//开关控件,固定大小51*31,frame中设置大小无效

//开关的打开状态
@property(nonatomic,getter=isOn) BOOL on;

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
//最后一个参数写UIControlEventValueChanged
//点击开关时触发



【UIActivityIndicatorView】
//加载等待提示控件,初始化的时候,设定风格样式,(联网小菊花)
- (id)initWithActivityIndicatorStyle:(UIActivityIndicatorViewStyle)style;
//UIActivityIndicatorViewStyleWhiteLarge,//控件的size固定

//一般直接设置中心点为view的中心点

//开始旋转和停止
- (void)startAnimating;
- (void)stopAnimating;

//用switch控制activity 的旋转状态

******************************************
【UIStepper】
//步进器 固定的size (94*29)修改无效, 事件驱动型控件

//步进器的值
@property(nonatomic) double value;
//最小和最大值(默认0到100)
@property(nonatomic) double minimumValue;
@property(nonatomic) double maximumValue;
//设置步长 (默认值为1 必须>0)(加减的时候改变的值)
@property(nonatomic) double stepValue;

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
//最后一个参数写UIControlEventValueChanged
//点击加减的时候触发

*********************************************
【UIProgressView】
//进度条,高度固定为2,设置无效

//进度条的值 固定为0到1
@property(nonatomic) float progress;

//用stepper控制progress的进度



*****************************************
【UIAlertView】
//警示框

//代理


UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@“title” message:@“mrs” delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alert show];
[alert release];

//代理方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSLog(@"buttonIndex:%d",buttonIndex);
}


【UIActionSheet】
//事件表格

//代理


UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"title" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@“内容1” otherButtonTitles:@"内容2”,@“内容3”,nil];
[sheet showInView:self.view];
[sheet release];

//事件表代理方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSLog(@"sheet index:%d",buttonIndex);
}

你可能感兴趣的:(iOS常用小控件集合)