mar*_*rko -2
你所要求的打破了封装,也许也没有意义。
实现此目的的一种更简洁的方法是添加一个类别并提供您自己的便利工厂(例如类)方法,而不是使用继承并进行一些假设UIFont。
@interface UIFont (MyUIFont)
@property (assign) CGFloat ascender;
@property (assign) CGFloat descender;
+(instancetype) UIFontWithLessSpacing;
@end
@implementation UIFont (MyUIFont)
+(instancetype) UIFontWithLessSpacing
{
UIFont *font = [UIFontWIthName:@"MyFont" size:12.0f];
font.ascender = 0.0;
font.descender = 0.0;
return font;
}
Run Code Online (Sandbox Code Playgroud)
有一些注意事项:
UIFont实际上响应选择器setAscender-setDescender它们隐藏在公共界面上| 归档时间: |
|
| 查看次数: |
936 次 |
| 最近记录: |