UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0,0,0,)] //初始化View
view.clipsToBounds = yes//剪切视图超出得部分
View.layer.cornerRadius = 10;//设置圆角
[self.window bringSubViewToFront:view];//将子视图放到最上层
[self.window sendSubviewToBack:view];//将子视图放到最下层去
View.hidden = no//隐藏视图,默认为no
NSLog(@"%@",NSStringFromSelector(_cmd));//方法打印
[button setBackGroundImage:[UIImage imageNamed:@"信息"]forState:UIControlStateNormal];//按钮添加图片,但是要设置为custom状态
[button setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];//指定状态对应的显示图片
[button setTitleColor:[UIColor whiteColor]]//设置按钮字体的颜色
NSLog(@"%@",button.nextResponder);//打印上一个响应者
NSLog(@"%@",button.nextResponder.nextResponder);//打印uiview上一个响应者
textField.borderStyle = UITextBorderStyleRoundedRect;//设置textfield的style
textField.PlaceHolder = @"";//显示提醒字体
textField.delegate = self;//textfield代理
//协议
- (bool)texeFieldShouldReturn:(UITextFidl*)textField{
[textField resignFirstResponder];//注销textile的第一响应者,回收键盘
}
- (bool)textFieldShouleBeginEditing:(uitextField*)textField{
return YES;//输入时候调用
}
- (bool)textFieldShouldEndEditing:(UITextField*)textfield{
return yes; //结束的时候开始调用
}
- (bool)textField:(uitextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(nesting *){//range输入的长度。replacementString限制输入数值或者英文
if(string.length > 0){
if(range.location > 0 || [string characterAtIndex:0] > '9'){
return no;//限制输入数字和长度
}
}
return yes;
}
- (void)toucherBegan:(asset*)touches withEvent:(UIEvent *)event{
[self.view endEditing:yes];//点击空白地方回收键盘
}
//滑条
UISlider *slidere = [[UISlider alloc]initWithFrame:CGRectMake(80, 500, 200, 10)];
slidere.minimumTrackTintColor = [UIColor redColor];
slidere.maximumTrackTintColor = [UIColor blueColor];
slidere.minimumValue = 0.2;//最小
slidere.maximumValue = 1;//最大
slidere.value = 1;//一开始就是最大值
slidere.minimumTrackTintColor = [UIColor redColor];
[slidere setValue:0.3 animated:YES];//用滑条设置透明度 ,一开始设置是0.3
[slidere addTarget:self action:@selector(sliderChange:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:slidere];
- (void)sliderChange:(UISlider *)sender{
NSLog(@"%f",sender.value);
self.view.alpha = sender.value;
}
//分段控件
UISegmentedControl *segmented = [[UISegmentedControl alloc]initWithItems:@[@"1",@"2",@"3",@"4"]];
segmented.frame = CGRectMake(30, 450, 300, 37);
// segmented.alpha = 0;
segmented.tintColor = [UIColor redColor];
[segmented addTarget:self action:@selector(segmentedChange:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:segmented];
//进度指示器
_indicatorView = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(30, 550, 300, 37)];
// indicatorView.center = self.view.center;
_indicatorView.bounds = CGRectMake(0, 0, 50, 50);
// _indicatorView.hidesWhenStopped = NO;//停止后不消失
_indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[self.view addSubview:_indicatorView];
[_indicatorView startAnimating];//进度圈开始转动
UIStepper *stepper = [[UIStepper alloc]initWithFrame:CGRectMake(100, 160, 50, 30)];
[self.view addSubview:stepper];
网友评论