lineSpacing UILabel的属性?(Is lineSpacing a property of UILabel?)

编程入门 行业动态 更新时间:2024-10-11 05:25:22
lineSpacing UILabel的属性?(Is lineSpacing a property of UILabel?)

我有一个属性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.lineSpacing

gives 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.

更多推荐

本文发布于:2023-08-04 18:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1419248.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   lineSpacing   UILabel   property

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!