- UIPageControl
创建:
UIPageControl *pageC = [[UIPageControl alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
-
常用属性
1.page控制器页数
pageC.numberOfPages = 5;
2.page控制器当前页数(默认0)
pageC.currentPage = 3;
3.page控制器页数颜色
pageC.pageIndicatorTintColor = [UIColor blackColor];
4.page控制器当前页数颜色 (默认白色)
pageC.currentPageIndicatorTintColor = [UIColor redColor];
5.page控制器单页时隐藏(默认NO)
pageC.hidesForSinglePage = YES;
6.更新page控制器的当前页码 (默认NO; 设置YES后,点击不会改变page控制器显示的当前页码点)
pageC.defersCurrentPageDisplay = YES;
-
常用方法
**1.根据页数自适应尺寸 **
[pageC sizeForNumberOfPages:3];
2.更新page控制器的当前页码(手动更新)
[pageC updateCurrentPageDisplay];
- UISwitch
创建:
UISwitch *yjswitch = [[UISwitch alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
-
常用属性
1.开关开启的颜色(默认绿色)
yjswitch.onTintColor = [UIColor blackColor];
2.未开启的颜色(默认白色)
yjswitch.tintColor = [UIColor redColor];
3.开关按钮颜色
yjswitch.thumbTintColor = [UIColor yellowColor];
4.开启开关 (默认NO)
yjswitch.on = YES;
或者动态设置开启
[yjswitch setOn:YES animated:YES];5.开启时图片
yjswitch.onImage = [UIImage imageNamed:@""];
6.未开启时图片
yjswitch.offImage = [UIImage imageNamed:@""];
- UISlider
slider.value = 55;
[slider setValue:55 animated:YES];
创建:
UISlider * slider = [[UISlider alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
-
常用属性
1.滑块最小值(默认0)
slider.minimumValue = 10;
2.滑块最大值(默认1)
slider.maximumValue = 100;
3.滑块动态变化(默认 NO)
这个属性设置为YES时在滑动时,其value就会随时变化,设置为NO,则当滑动结束时,value才会改变
slider.continuous = YES;4.滑块的左边图片
slider.minimumValueImage = [UIImage imageNamed:@"leftitem_down"];
或者动态设置开启5.滑块的右边图片
slider.maximumValueImage = [UIImage imageNamed:@"leftitem_down"];
6.已划过线条的颜色
slider.minimumTrackTintColor = [UIColor redColor];
7.未滑过线条的颜色
slider.maximumTrackTintColor = [UIColor greenColor];
8.滑块的颜色
slider.thumbTintColor = [UIColor blackColor];
9.设置滑块值
slider.value = 55;
或动态设置
[slider setValue:55 animated:YES];
-
方法
设置的内容和上文中的对应属性一样,只是添加可根据状态来设置
[slider setThumbImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
[slider setMinimumTrackImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
[slider setMaximumTrackImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
一般用于在子类化按钮的时候重载下面这些方法, 返回CGRect,指明按钮每组成部分的边界,达到定制属于自己的按钮类。
注意:不要直接调用这些方法, 这些方法是你写给系统调用的。
- (CGRect)minimumValueImageRectForBounds:(CGRect)bounds;
- (CGRect)maximumValueImageRectForBounds:(CGRect)bounds;
- (CGRect)trackRectForBounds:(CGRect)bounds;
- (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value;
-
获取信息方法
UIImage *thumbImage = [slider thumbImageForState:UIControlStateNormal];
UIImage *minImage = [slider minimumTrackImageForState:UIControlStateNormal];
UIImage *maxImage = [slider maximumTrackImageForState:UIControlStateNormal];
UIImage *thumbImage1 = slider.currentThumbImage;
UIImage *minImage1 = slider.minimumValueImage;
UIImage *maxImage1 = slider.maximumValueImage;