我有一个属性lineSpacing安装的UILabel的子类,如下所示:
var lineSpacing = CGFloat(20.0)当我这里有这个时候,它会推动文本,即使它不用于任何东西,我删除了除该属性外的所有代码:
class CustomLabel : UILabel { var lineSpacing = CGFloat(20.0) }它仍然被推高,我改变了财产的名称,并修复它,我只是想知道这是从哪里来的,因为我无法从UILabel访问lineSpacing
regularLabel.lineSpacing给出错误。
I have a subclass of UILabel with a property lineSpacing setup like so:
var lineSpacing = CGFloat(20.0)When I have this here it pushes up the text, even though it isn't used for anything, I removed all the code except for that property:
class CustomLabel : UILabel { var lineSpacing = CGFloat(20.0) }and it is still pushed up, I changed the name of the property and it fixed it, I was just wondering where this is coming from as I can't access lineSpacing from a UILabel
regularLabel.lineSpacinggives an error.
最满意答案
是的, UILabel有一个无证的非公开lineSpacing属性。 您可以在从运行时Objective-C元数据创建的头文件中看到它:
https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UILabel.h
由于它不是公开的,因此如果将它提交给App Store,则覆盖它(即使意外)可能会导致Apple拒绝您的应用程序。
Yes, UILabel has an undocumented, non-public lineSpacing property. You can see it in this header file that was created from the runtime Objective-C metadata:
https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UILabel.h
Since it's not public, overriding it (even accidentally) may cause Apple to reject your app if you submit it to the App Store.
更多推荐
发布评论