您的位置:首页 > 移动开发 > IOS开发

IOS 常用控件的使用

2015-09-29 00:00 459 查看
UIButton

//初始化 位置
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width-180, 45, 80, 30)];
[btn.layer setCornerRadius:5.0]; //设置矩形四个圆角半径
[btn.layer setBorderWidth:1.0]; //边框宽度
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 0.9, 0.9, 0.9, 1 });
[btn.layer setBorderColor:colorref];//边框颜色
[btn setTitle: @"Button" forState: UIControlStateNormal];
btn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
[btn setBackgroundColor: [UIColor blueColor]];
[btn setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
[btn addTarget:self action:@selector(btnActioin:) forControlEvents:UIControlEventTouchUpInside];
btn.tag = 1;
[btn setImage:[UIImage imageNamed:@"trade_choose_default"] forState:UIControlStateNormal];

UIColor

[UIColor colorWithRed:0.95 green:0.93 blue:0.92 alpha:1];

UILabel

label.text=@"Label";
label.hidden=YES;


UIImage

[UIImage imageNamed:@"trade_choose_default"]

// UIImage、UIImageView 显示 URL 图片
[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"URL"]]];

UIView

//设置动画
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.6];//动画时间长度,单位秒,浮点数
//改变视图位置
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
self.addressPicker.frame = CGRectMake(0, 380, 320, 180);
//绑定视图事件
[UIView setAnimationDelegate:self];
// 动画完毕后调用 animationFinished
[UIView setAnimationDidStopSelector:@selector(animationFinished)];
//开始执行动画
[UIView commitAnimations];

//将视图置前
[self.view bringSubviewToFront:logisticsPicker];

-(void)animationFinished{
NSLog(@"动画结束!");
}

UITextField

[textField setBorderStyle:UITextBorderStyleRoundedRect]; //外框类型
textField.placeholder = @"password"; //默认显示的字
textField.secureTextEntry = YES; //密码
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: