图片充满整个按钮
[button setBackgroundImage:[UIImage imageNamed:@"picture"] forState:UIControlStateNormal];
图片保持原有大小
[button setImage:[UIImage imageNamed:@"fitPic"] forState:UIControlStateNormal];
设置button的字体大小
button.titleLabel.font = [UIFont systemFontOfSize:20];
Lable.numberofLines = NSIntegerMax;//设置多行
[Lable sizeToFit];//自动适应文本
self.textfield.secureTextEntry = YES;//密码效果
textFiled.keyboardType = UIKeyboardTypeNamePhonepad;//设置键盘类型
self.textfield.inputAcessoryView = view;//通过自定义的视图取代键盘
self presentViewController:viewcontroller animatal:YES completion:^{
}];
#pragma mark 输入框开始编辑
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
if (textField.frame.origin.y >HEIGHT / 2) { //originX和originY对应着该对象在其superview中的坐标,也就是说他是一个相对坐标。
//计算当前textfield距离屏幕中心的距离
CGFloat height = textField.frame.origin.y - HEIGHT / 2;
self.view.center = CGPointMake(self.view.center.x, self.view.center.y - height);
}
return YES;
}
#pragma mark 结束编辑时执行这个方法
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
if (textField.frame.origin.y > HEIGHT / 2) {
CGFloat height = textField.frame.origin.y - HEIGHT / 2;
self.view.center = CGPointMake(self.view.center.x, self.view.center.y + height);
}
return YES;
}
//毛玻璃效果
UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectView = [[UIVisualEffectView alloc]initWithEffect:effect];
协议: 声明协议, 声明代理人属性, 代理人执行协议方法, 签协议, 设置代理人, 执行协议方法
//设置随机的背景颜色
self.view.backgroundColor = [UIColor colorWithRed:arc4random() %256 / 255.0 green:arc4random() % 256 / 255.0 blue:arc4random() % 256 / 255.0 alpha:1.0];
uitextfield,uibutton,uiswitch,uistetpper, uisegmentedcontrol,uipagecontrol都是继承uicontrol继承uiview
slider.maximumValue = 5;//指定最大值
slider.minimumValue = 0.5;//指定最小值
slider.value = 3;//指定初始值
//用translucent设置成不透明,默认是半透明
// self.navigationController.navigationBar.translucent = NO;
//修改背景颜色不是所有的背景颜色都是backgroundcolor
// self.navigationController.navigationBar.barTintColor = [UIColor brownColor];
//自定义返回按钮
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithTitle:@"自定义按钮" style:UIBarButtonItemStyleDone target:self action:nil];
self.navigationItem.backBarButtonItem = backButton;
self.tabBarController.tabBar.hidden = YES;//隐藏tabbar
原文:http://www.cnblogs.com/guominghao/p/5232019.html