Oleg Korban
Oleg Korban

Reputation: 269

Custom font with size classes in iOS

I'm trying to add 2 different font sizes for iphone and ipad layouts using size classes. It works cool with a default System font but doesn't work with custom font(I'm using PragmataPro in my project). If I add the second size for wR hR then font looks correctly in interface builder(I even checked xml) but in simulator and on device it becomes System instead of PragmataPro. But if I remove wR hR(or whatever layout I'm using for another size) then font shows correctly. Any idea how to solve this issue? Thanks!

Upvotes: 7

Views: 1638

Answers (3)

user4415984
user4415984

Reputation:

The 'custom' is there to define one single setting per type class. If you don't define a 'custom' library with all the variations you want than I don't really think there to be a solution, mainly because by 'custom' you mean ONE SINGLE COMPONENT OF A GIVEN LIST OF CHOICES...

Upvotes: -1

Shruti
Shruti

Reputation: 1849

Subclass UILabel and override "layoutSubviews" method like:

- (void)layoutSubviews
{
 [super layoutSubviews];
 // Implement font logic depending on screen size
  self.font = [UIFont fontWithName:@"CustomFont" size:self.font.pointSize];
}

Upvotes: 3

Related Questions