gpt4 book ai didi

ios - 文本在圆形 UIButton iOS 中不可见

转载 作者:行者123 更新时间:2023-11-29 01:23:09 25 4
gpt4 key购买 nike

我正在添加一个圆形的 UIButton,如下所示:

-(void)addInfoButton
{
UIButton *pButton = [UIButton buttonWithType:UIButtonTypeCustom];

[pButton addTarget:self
action:@selector(infoButtonDidTap:)
forControlEvents:UIControlEventTouchUpInside];

pButton.frame = [self getInfoButtonFrame];

pButton.clipsToBounds = NO;

//half of the width
pButton.layer.cornerRadius = BUTTON_HEIGHT/2.0f;
pButton.layer.borderColor = self.tintColor.CGColor;
pButton.layer.borderWidth = 2.0f;

pButton.titleLabel.text = @"F";

pButton.titleLabel.textColor = self.tintColor;
pButton.titleLabel.textAlignment = NSTextAlignmentCenter;

self.filterInfoButton = pButton;

[self addSubview:pButton];
}

显示按钮时,文本“F”不可见。可能是什么原因?

编辑:将角半径设置为 0 时,文本可见。但是,按钮不是圆形的。

最佳答案

您可以使用

设置 UIButton 的标题
- setTitle:forState:

Sets the title to use for the specified state.

使用属性 titleLabel 不会设置用于自定义按钮标题标签的文本。

titleLabel 

A view that displays the value of the currentTitle property for a button. (read-only) Although this property is read-only, its own properties are read/write. Use these properties primarily to configure the text of the button. For example:

button.titleLabel.font = UIFont.systemFontOfSize(12)

关于ios - 文本在圆形 UIButton iOS 中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34358125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com