开发者

UIButton - rounded corners in highlight state

开发者 https://www.devze.com 2023-02-08 15:52 出处:网络
In the image below the button is being pressed. The shadow is square. How do I make the shadow have rou开发者_运维知识库nded edges?

In the image below the button is being pressed. The shadow is square. How do I make the shadow have rou开发者_运维知识库nded edges?

UIButton - rounded corners in highlight state


Here's how I did it:

1) Subclass the UIButton

2) Change the Layer like this:

public class GalleryButton: UIButton
    {

        public GalleryButton (RectangleF frame) : base(frame)
        {
            this.Layer.CornerRadius = 12f;
            this.Layer.MasksToBounds = true;
            this.Layer.BorderWidth = 0f;
        }


I think if you have a transparent png, it works as it is.

0

精彩评论

暂无评论...
验证码 换一张
取 消