小编Owa*_*unt的帖子

如何将多行文本添加到UIButton?

我有以下代码......

UILabel *buttonLabel = [[UILabel alloc] initWithFrame:targetButton.bounds];
buttonLabel.text = @"Long text string";
[targetButton addSubview:buttonLabel];
[targetButton bringSubviewToFront:buttonLabel];
Run Code Online (Sandbox Code Playgroud)

...我的想法是我可以为按钮添加多行文本,但文本总是被UIButton的backgroundImage遮盖.用于显示按钮子视图的日志记录调用显示已添加UILabel,但无法看到文本本身.这是UIButton中的错误还是我做错了什么?

cocoa-touch uibutton uikit ios

358
推荐指数
13
解决办法
17万
查看次数

标签 统计

cocoa-touch ×1

ios ×1

uibutton ×1

uikit ×1