我有下面这段代码...
UILabel *buttonLabel = [[UILabel alloc] initWithFrame:targetButton.bounds];
buttonLabel.text = @"Long text string";
[targetButton addSubview:buttonLabel];
[targetButton bringSubviewToFront:buttonLabel];
我想实现按钮的多行文本,但按钮的backgroundImage始终遮挡文本。调用日志显示该UIButton的子视图中已添加了UILabel,但文本本身无法显示。这是UIButton的错误还是我的操作有误?
titleLabel
是按钮的标题标签,?.
表示如果此属性不为nil,则执行后面的代码,否则跳过该语句。 - ma11hew28