Quantcast
Channel: Active questions tagged uipickerview - Stack Overflow
Viewing all articles
Browse latest Browse all 592

How to change UIPickerView font size

$
0
0

How do I change the font size. My code below is not working. I'm using xcode7.1 and swift 2 on iOS 9.1.

func pickerView(pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
    var attributedString: NSMutableAttributedString
    let myAttribute = [ NSFontAttributeName: UIFont(name: "Chalkduster", size: 13.0)! ]
    switch component {
    case 0:
        attributedString = NSMutableAttributedString(string: firstFieldArray[row], attributes: myAttribute )
    case 1:
        attributedString = NSMutableAttributedString(string: secondFieldArray[row], attributes: [NSForegroundColorAttributeName : UIColor.redColor()])
    default:
        attributedString = NSMutableAttributedString(string: firstFieldArray[row], attributes: myAttribute )
    }

    return attributedString
}

case 1 is working perfectly, while case 0 isn't changing it's fontsize.


Viewing all articles
Browse latest Browse all 592

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>