UIButton看起来像UIBarButtonItem

时间:2013-01-17 07:48:27

标签: ios

  

可能重复:
  UIBarButtonItem with Image

我想创建一个类似于UIButton项目的UIBarButton(即带有圆角和渐变背景)并将其添加到我的视图中:

Gradient button

我该怎么做?

1 个答案:

答案 0 :(得分:1)

    _btn1 = [[UIButton alloc] initWithFrame:CGRectMake(50, 1500, 100, 200)];
    _btn1.layer.cornerRadius = 5;
    _btn1.layer.masksToBounds = YES;
    [_btn1 setBackgroundImage:[UIImage imageNamed:@"img2.jpg"] forState:UIControlStateNormal];

如果您想自己绘制图层,可以查看MAConfirmButton