ios - UIPageControl - UISwitch -

2016-09-29  本文已影响61人  fjytqiu

- UIPageControl

创建:
UIPageControl *pageC = [[UIPageControl alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];

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)];

6.未开启时图片

yjswitch.offImage = [UIImage imageNamed:@""];

- UISlider

slider.value = 55;
[slider setValue:55 animated:YES];

创建:
UISlider * slider = [[UISlider alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];

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;

上一篇 下一篇

猜你喜欢

热点阅读