1

I'm using UIPickerView but in a willing to custom the font size in a row in a more efficient way.

First I have tried viewForRow: to create a label by myself, and call titleForRow: in it to acquire the text content that need to show. It works, but I'm not sure if it is a proper way.

Then I delete the method viewForRow: and tried attributedTitleForRow: that successfully changed the text color using NSForegroundColorAttributeName, but failed to set font size using NSFontAttributeName by next line. I doubt if there is a constraint mechanism that forbid/autoresize the font size change in UIPickerView? (The UIPickerView actually have a constraint of height combines to 162, 180 or 216 that I can only use CGAffineTransformMakeScale to custom it, so I really doubt it has another constraints.)

Now I'm very confused if there is a way modify the font size without implement viewForRow:, thanks.

Okay~~~ Now I'm implementing the viewForRow: method.

  • your approach is right using attributed title. but you should use custom view as if your content will be of more size compared to width of pickerview and height of row then to adjust size and number of lines you need custom view. Refer this link http://stackoverflow.com/questions/20698547/how-can-i-change-text-font-in-picker-in-ios-7 – Ruchish Shah Jul 23 '15 at 03:58
  • @RuchishShah thanks. so that means if I just want to set a custom font size using default row height and picker view frame, I still need to implement viewForRow: ? – Tzelann Minyi Jul 23 '15 at 05:51

0 Answers0