[置顶] IOS的UIButton单状态,圆角,边框,去除按下时的状态。

设置Button为圆角。且去除了Button的按下时的状态。
    UIButton *btn2 = [[UIButton alloc]initWithFrame:CGRectMake(5, 70, 310, 52)];
    UIImage *img2 = [UIImage imageNamed:@"[email protected]"];
    [btn2 setBackgroundImage:[img2 stretchableImageWithLeftCapWidth:20 topCapHeight:0] forState:UIControlStateNormal];
    btn2.adjustsImageWhenHighlighted = NO;
    btn2.layer.backgroundColor =[UIColor orangeColor].CGColor;
    
    NSLog(@"default cornerRadius is %f, default borderwidth is %f, buttontype is %d", btn2.layer.cornerRadius, btn2.layer.borderWidth, btn2.buttonType);
    btn2.layer.cornerRadius = 10.0;
    btn2.layer.borderWidth = 1.0;
    //btn2.layer.borderColor = [UIColor grayColor].CGColor;

你可能感兴趣的:(ios,button)