在 CalloutAccessoryView 中更改 UIButton 的文本颜色

Change text color of UIButton in CalloutAccessoryView

我使用此代码在我的 CalloutView 中创建了一个 UIButton

var button  = UIButton.buttonWithType(UIButtonType.System) as! UIButton
            button.frame = CGRectMake(100, 100, 100, 50)
            button.backgroundColor = UIColor.redColor()
            button.setTitle("No", forState: UIControlState.Normal)
            button.addTarget(self, action: "Action:", forControlEvents: UIControlEvents.TouchUpInside)
            anView.rightCalloutAccessoryView = button

如何更改 UIButton 的文本颜色?

您可以像这样更改 UIButton 的 title/text 颜色:

button.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)