How to change font and color of UIRefreshControl

I am trying to add pull to update to a table view controller, so I worked on the functionality and then I work on the layout. The functionality works fine, but I have some layout issues, I want to change the font and font color of the header. I changed them to the Update Controller Attribute on the storyboard, but every time I run the project, all my settings return to default. So, I tried to work with them using code, and now I can change the background and tintColor, but I can not change the font and color. Could you please help me and this is my code:

    refresh.backgroundColor = UIColor(red: 220/255, green: 220/255, blue: 220/255, alpha: 1)
    refresh.tintColor = UIColor(red: 155/255, green: 155/255, blue: 154/255, alpha: 1)
    var label:NSAttributedString = NSAttributedString(string: "Refresh!!!")

    refresh.attributedTitle = label

Thank,

+4
source share
3

, , , - , .

.

let attributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
let attributedTitle = NSAttributedString(string: "title", attributes: attributes)

refreshControl.attributedTitle = attributedTitle

.

[NSFontAttributeName: UIFont(name: fontName, size: size)]
+11

Swift 3:

let attributes = [NSForegroundColorAttributeName: UIColor.white, NSFontAttributeName: UIFont.systemFont(ofSize: 12)]
refreshControl.attributedTitle = NSAttributedString(string: "Test text", attributes: attributes)
+2

Swift 4:

let attributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
refreshControl.attributedTitle = NSAttributedString(string: "Refreshing please wait", attributes: attributes)
+2
source

All Articles