2015-08-31 83 views
0

我正试图在iPhone上创建以下按钮而没有成功。iPhone UIButton在一侧和圆角处有阴影/边框

我已经看到了stackoverflow中的答案,但我无法得到相同的结果。

它基本上是一个简单的颜色和底部的阴影,继续圆角。

image

+0

简单的就是用图像。你是否试图以编程的方式做到这一点?如果是这样,请查看'drawRect:'绘图并在状态更改时重新绘制。 –

回答

2

尝试使用photoshop制作此按钮。并使用该图像作为将backgroundImage为您的按钮

0

圆角半径可以通过执行实现这一目标:

self.button.layer.cornerRadius = yourDesiredRadius; 

边框是有点难以实现。我建议你只需使用一个图像,并将其用作按钮的背景图像。 您可以在Interface Builder中设置背景图像。或者,以编程方式:

UIImage *image = [UIImage imageNamed:@"imageName"]; 
[self.button setImage:image forState:UIControlStateNormal]; 
-1

老实说,最好的办法做这种按钮的使用背景图片用于正常状态,并强调国家:

self.setBackgroundImage(UIImage(named: "buttonBackground"), forState: UIControlState.Normal) 
self.setBackgroundImage(UIImage(named: "pressedButtonBackground"), forState: UIControlState.Highlighted) 

这是他们将如何看: enter image description here

enter image description here

下面是蓝色基调两个图像:

buttonBackground.pdfpressedButtonBackground.pdf

如果你想利用这些图像的任何尺寸,你可以切片相似图片如下:

enter image description here

enter image description here