在CalloutAccessoryView中更改UIButton的文本颜色

时间:2015-05-25 16:02:04

标签: ios swift uibutton

我使用此代码在UIButton中创建CalloutView

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的文字颜色?

1 个答案:

答案 0 :(得分:0)

您可以更改UIButton的标题/文字颜色,如下所示:

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