以编程方式创建一个 UIButton,但没有点击效果(仅文本效果)
Programatically created a UIButton, but no click effect (text effect only)
我创建了一个这样的按钮,但是当我点击它时没有任何变化的效果。
UIButton *button = [[UIButton alloc] init];
button.translatesAutoresizingMaskIntoConstraints = NO;
[button setTitle: @"xxxxx" forState: UIControlStateNormal];
[button setTitleColor: [UIColor colorWithRed:0.98 green:0.44 blue:0.05 alpha:1] forState: UIControlStateNormal];
我不会使用两张图片,我只是想稍微改变一下文字。就像将一个新按钮拖到 UIViewController 上一样。
我错过了什么?
单击按钮时必须设置标题和标题颜色。
[button setTitle: @"clicked" forState: UIControlStateHighlighted];
[button setTitleColor: [UIColor redColor] forState: UIControlStateHighlighted];
我创建了一个这样的按钮,但是当我点击它时没有任何变化的效果。
UIButton *button = [[UIButton alloc] init];
button.translatesAutoresizingMaskIntoConstraints = NO;
[button setTitle: @"xxxxx" forState: UIControlStateNormal];
[button setTitleColor: [UIColor colorWithRed:0.98 green:0.44 blue:0.05 alpha:1] forState: UIControlStateNormal];
我不会使用两张图片,我只是想稍微改变一下文字。就像将一个新按钮拖到 UIViewController 上一样。
我错过了什么?
单击按钮时必须设置标题和标题颜色。
[button setTitle: @"clicked" forState: UIControlStateHighlighted];
[button setTitleColor: [UIColor redColor] forState: UIControlStateHighlighted];