/******************************
UIButtonTypeCustom = 0, 自定义(常用)
UIButtonTypeDetailDisclosure, 感叹号
UIButtonTypeInfoLight, 感叹号
UIButtonTypeInfoDark, 感叹号
UIButtonTypeContactAdd, +号
UIButtonTypeRoundedRect
******************************/
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(100, 100, 100, 100);
/******************************
UIControlStateNormal 默认
UIControlStateHighlighted 高亮
UIControlStateSelected 选中
******************************/
button.enabled = NO;
- (void)setTitle:(nullable NSString *)title forState:(UIControlState)state;
- (void)setTitleColor:(nullable UIColor *)color forState:(UIControlState)state;
- (void)setImage:(nullable UIImage *)image forState:(UIControlState)state;
- (void)addTarget:(nullable id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
UITextFiled
UITextField * textFiled = [[UITextField alloc] initWithFrame:CGRectMake(50, 50, 60, 40)];
textFiled.borderStyle = UITextBorderStyleRoundedRect;
textFiled.keyboardType = UIKeyboardTypeDefault ;
textFiled.returnKeyType = UIReturnKeyEmergencyCall;
/***************************************
UITextFieldViewModeNever, 从不
UITextFieldViewModeWhileEditing, 编辑时
UITextFieldViewModeUnlessEditing, 不编辑时
UITextFieldViewModeAlways 总是
***************************************/
textFiled.clearButtonMode = UITextFieldViewModeUnlessEditing;
textFiled.placeholder = @"请输入密码";
textFiled.secureTextEntry = YES;
/***************************************
UITextAutocapitalizationTypeNone, 全都不大写
UITextAutocapitalizationTypeWords, 单词首字母大写
UITextAutocapitalizationTypeSentences, 句子首字母大写
UITextAutocapitalizationTypeAllCharacters, 全都大写
***************************************/
textFiled.autocapitalizationType = UITextAutocapitalizationTypeWords;
/***************************************
UITextAutocorrectionTypeDefault, 默认
UITextAutocorrectionTypeNo, 关
UITextAutocorrectionTypeYes, 开
***************************************/
textFiled.autocorrectionType = UITextAutocorrectionTypeYes;
UIslider
UISlider * slider = [[UISlider alloc] initWithFrame:CGRectMake(100, 100, 200, 30)];
slider.maximumValue = 100;
slider.minimumValue = 0;
slider.value = 20;
slider.maximumTrackTintColor = [UIColor yellowColor];
slider.minimumTrackTintColor = [UIColor redColor];
[slider setThumbImage:[UIImage imageNamed:@"playing_btn_in_myfavor"] forState:UIControlStateNormal];
- (void)setMinimumTrackImage:(nullable UIImage *)image forState:(UIControlState)state;
- (void)setMaximumTrackImage:(nullable UIImage *)image forState:(UIControlState)state;
[slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
UISwitch
@property(nullable, nonatomic, strong) UIColor *onTintColor
@property(null_resettable, nonatomic, strong) UIColor *tintColor
@property(nullable, nonatomic, strong) UIColor *thumbTintColor
@property(nullable, nonatomic, strong) UIImage *onImage
@property(nullable, nonatomic, strong) UIImage *offImage
@property(nonatomic,getter=isOn) BOOL on;
[switch addTarget:self action:@selector(switchOn) forControlEvents:UIControlEventValueChanged];
UISegmentedControl
UISegmentedControl * segmentControl = [[UISegmentedControl alloc] initWithItems:@[@"start",@"stop",@"HMT"]];
- (void)insertSegmentWithTitle:(nullable NSString *)title atIndex:(NSUInteger)segment animated:(BOOL)animated;
- (void)insertSegmentWithImage:(nullable UIImage *)image atIndex:(NSUInteger)segment animated:(BOOL)animated;
- (void)setTitle:(nullable NSString *)title forSegmentAtIndex:(NSUInteger)segment;
- (void)setImage:(nullable UIImage *)image forSegmentAtIndex:(NSUInteger)segment;
- (void)removeSegmentAtIndex:(NSUInteger)segment animated:(BOOL)animated;
[segmentControl addTarget:self action:@selector(selector) forControlEvents:UIControlEventValueChanged];