您的位置:首页 > 产品设计 > UI/UE

UIButton

2016-06-26 01:51 351 查看
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIButton *button  = [UIButton buttonWithType:UIButtonTypeSystem] ;
button.frame = CGRectMake(60,100,200,200) ;
[button setTitle:@"button" forState:UIControlStateNormal];
button.backgroundColor = [UIColor redColor];
//[button setBackgroundImage:[UIImage imageNamed:@"灯泡.jpg"] forState:UIControlStateNormal];
//[button setImage:[[UIImage imageNamed:@"灯泡.jpg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
//button.contentEdgeInsets = UIEdgeInsetsMake(20, 0, 0, 0); //上左下右
//button.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 40, 0);
//button.titleEdgeInsets = UIEdgeInsetsMake(30, 0, 0, 0);
//    button.adjustsImageWhenHighlighted = YES;
button.showsTouchWhenHighlighted = YES;
button.tintColor = [UIColor purpleColor];
button.titleLabel.font = [UIFont boldSystemFontOfSize:30];
[self.view addSubview:button];
button.layer.masksToBounds = YES;
button.layer.cornerRadius = 30;
[button addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
//button.enabled = NO;
}
- (void)clickBtn:(UIButton *)btn{
[btn setBackgroundColor:[UIColor colorWithRed:arc4random()%255/255.0
green:arc4random()%255/255.0
blue:arc4random()%255/255.0
alpha:arc4random()%255/255.0]];
[self.view setBackgroundColor:[UIColor colorWithRed:arc4random()%255/255.0
green:arc4random()%255/255.0
blue:arc4random()%255/255.0
alpha:arc4random()%255/255.0]];

NSLog(@"%@",btn);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: