在UI按钮中设置图层外层?

时间:2015-06-19 09:21:00

标签: ios objective-c uibutton uiimage calayer

enter image description here

我想要这种类型的按钮 我已经尝试过pictureBtn,UIbutton,我给了它一个5像素的清晰颜色角半径,并添加了一个像下面的相机,但最后外白线如何处理这个可以任何人有想法或控制之类的东西。

3 个答案:

答案 0 :(得分:1)

对于此设计,将按钮放在一个视图中,并在视图和按钮之间设置5个像素间隙。 比设置2像素边界的视图。

答案 1 :(得分:1)

通过属性setImage而不是setBackgroundImage设置图像, 做UIButton backgroungColor清晰的颜色, 并为UIButton设置边框

答案 2 :(得分:1)

这是我的解决方案的输出代码 -

    UIButton *picBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 60, 60)];

    [picBtn setImage:[UIImage imageNamed:@"CM.png"] forState:UIControlStateNormal];

    [picBtn setBackgroundColor:[UIColor clearColor]];

    [picBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];

    [picBtn.layer setCornerRadius:picBtn.frame.size.height/2];

    [picBtn.layer setBorderWidth:2];

    [picBtn.layer setBorderColor:[[UIColor grayColor] CGColor]];
相关问题