scaledValueForValue: called on a font that doesn't have a text style set

前端 未结 8 2068
暗喜
暗喜 2020-12-24 01:46

I am currently using the Xcode 6 pre release (not beta) and the simulator on OS X 10.10 Yosemite beta 7. I am trying to build a project developed in xcode 6, but the app cra

8条回答
  •  遥遥无期
    2020-12-24 02:01

    Finally found workaround. It is simple, you just need to construct font in other direction :)

    // 1. Grab your custom font
    CGFloat size = 17.0f;
    UIFont *font = [UIFont fontWithName:@"Brandon Grotesque" size:size];
    
    // 2. Get descriptor for your font and create new descriptor with
    UIFontDescriptorTextStyleAttribute and UIFontDescriptorSizeAttribute attributes from it.
    
    UIFontDescriptor *des = [[font fontDescriptor] fontDescriptorByAddingAttributes:@{
       UIFontDescriptorTextStyleAttribute: UIFontTextStyleBody, // You can tune this style based on usage
       UIFontDescriptorSizeAttribute: @(size)
    }];
    
    // 3. Get your font
    UIFont *finalFont = [UIFont fontWithDescriptor:des size:0.0]
    

提交回复
热议问题