iOS- Detect current size classes on viewDidLoad

As of iOS 8 UIViewController adopts the UITraitEnvironment protocol. This protocol declares a property named traitCollection which is of type UITraitCollection. You can therefor access the traitCollection property simply by using self.traitCollection UITraitCollection has two properties that you want to access named horizontalSizeClass and verticalSizeClass Accessing these properties return an NSInteger. The enum that defines … Read more

Custom Font Sizing in Xcode 6 Size Classes not working properly with Custom Fonts

Fast fix: 1) Set fonts as System for size classes 2) Subclass UILabel and override “layoutSubviews” method like: – (void)layoutSubviews { [super layoutSubviews]; // Implement font logic depending on screen size if ([self.font.fontName rangeOfString:@”bold” options:NSCaseInsensitiveSearch].location == NSNotFound) { NSLog(@”font is not bold”); self.font = [UIFont fontWithName:@”Custom regular Font” size:self.font.pointSize]; } else { NSLog(@”font is bold”); … Read more

tech