删除以编程方式创建的自定义按钮的边框

问题描述 投票:5回答:3

我知道通过以下方式将边框设置为按钮,

button.layer.cornerRadius = 0.0;
button.layer.borderWidth = 2.5;
button.layer.borderColor = [[UIColor darkGrayColor] CGColor];

但我需要知道如何删除或删除按钮的边框?

iphone uibutton
3个回答
14
投票
button.layer.borderWidth = 0.0;

会使边界看不见。


1
投票
button.layer.borderColor = [UIColor colorWithRed:0.3 green:0.6 blue:0.9 alpha:0.1];
//                                set 'alpha' to something less than 1. -----^^^

试试这个 !


0
投票

在UILabel上这不起作用,我使用了以下(考虑到你只添加了1个Sublayer)(这是Mono C#,但你可以很容易地翻译它)

label.Layer.Sublayers[0].RemoveFromSuperLayer();
© www.soinside.com 2019 - 2024. All rights reserved.