简述UISwitch的属性和用法

UISwitch属性

1. onTintColor

处于on时switch 的颜色
    switchImage.onTintColor = [UIColor grayColor];

2.tintColor

处于off时switch 的颜色

switchImage.tintColor = [UIColor greenColor];

3.onImage

设置on 的图标
    switchImage.onImage = [UIImage imageNamed:@"1.png"];

4. offImage

设置off的图标
 switchImage.offImage = [UIImage imageNamed:@"4.png"];

5. on

设置switch的开关

swithImage.on = YES;

6.thumbTintColor

设置拇指颜色

swithImage.thumbTintColor = [UIColor redColor];

效果:

7.增加事件响应机制

监听的是这个事件:UIControlEventValueChanged,值改变事件

[switchImage addTarget:self action:@selector(switchOn) forControlEvents:UIControlEventValueChanged];

时间: 2024-07-31 12:49:10

简述UISwitch的属性和用法的相关文章

简述UIView的属性和用法

1.alpha 设置视图的透明度.默认为1. // 完全透明 view.alpha = 0; // 不透明 view.alpha = 1; 2.clipsToBounds // 默认是NO,当设置为yes时,超出当前视图的尺寸的内容和子视图不会显示. view.clipsToBounds = YES; 3.hidden // 默认是NO,当设置为yes,视图就看不见了. view.hidden = YES; 4.userInteractionEnabled // 默认为YES,如果设置为No,v

简述UITableView的属性和用法

UITableView UITableView内置了两种样式:UITableViewStylePlain,UITableViewStyleGrouped   <UITableViewDataSource,UITableViewDelegate>里的方法: tableView处理步骤 1.有多少组 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 2.第section组头部控件有多高 - (CGFloat)tabl

简述UITextField的属性和用法

0.     enablesReturnKeyAutomatically 默认为No,如果设置为Yes,文本框中没有输入任何字符的话,右下角的返回按钮是disabled的. 1.borderStyle 设置边框样式,只有设置了才会显示边框样式 text.borderStyle = UITextBorderStyleRoundedRect; typedef enum { UITextBorderStyleNone, UITextBorderStyleLine, UITextBorderStyleB

简述UILabel的属性和用法

UILabel属性 1.text:设置标签显示文本. label.text = @"我是Label"; 2.attributedText:设置标签属性文本. NSString *text = @"first"; NSMutableAttributedString *textLabelStr = [[NSMutableAttributedString alloc] initWithString:text]; [textLabelStr setAttributes:@{

简述UISlide的属性和用法

UISlide属性   1.   minimumValue  : 当值可以改变时,滑块可以滑动到最小位置的值,默认为0.0 _slider.minimumValue = 10.0; 2.   maximumValue : 当值可以改变时,滑块可以滑动到最大位置的值,默认为1.0 _slider.maximumValue = 100.0; 3.   continuous : 如果设置YES,在拖动滑块的任何时候,滑块的值都会改变.默认设置为YES [_slider setContinuous:NO

简述UIButton的属性和用法

UIButton属性 1.UIButton状态: UIControlStateNormal          // 正常状态    UIControlStateHighlighted     // 高亮状态    UIControlStateDisabled        // 禁用状态     UIControlStateSelected        // 选中状态     UIControlStateApplication     //      UIControlStateReserve

给iOS开发新手送点福利,简述UIImagePickerController的属性和用法

1.+(BOOL)isSourceTypeAvailable:(UIImagePickerControllerSourceType)sourceType;         // 检查指定源是否在设备上可用. [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary];  //检查照片源是否可用 2.allowsEditing 默认NO 是否允许编辑 [imagePick

简述UIImagePickerController的属性和用法

1.+(BOOL)isSourceTypeAvailable:(UIImagePickerControllerSourceType)sourceType;         // 检查指定源是否在设备上可用. [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary];  //检查照片源是否可用 2.allowsEditing 默认NO 是否允许编辑 [imagePick

简述UIActivityIndicatorView的属性和用法

UIActivityIndicatorView 1.   activityIndicatorViewStyle 设置指示器的样式 UIActivityIndicatorViewStyleWhiteLarge UIActivityIndicatorViewStyleWhite  (默认样式) UIActivityIndicatorViewStyleGray 2.hidesWhenStopped 当停止动画的时候,是否隐藏.默认为YES. 3. 实例化指示器对象,根据样式设置尺寸,不需要手动设置.