我添加了 2 个 UIButtons 以在 xib 文件中查看。我已将第一个按钮的自定义类设置为 AButtonTest。这个类的实现是空的:
@implementation AButtonTest
@end
我运行 ios 6 模拟器:
如您所见,左侧的按钮看起来有所不同。为什么?
最佳答案
当您继承 UIButton
时,默认按钮类型是 UIButtonTypeCustom
而不是 UIButtonTypeSystem
。显然你的第一个按钮是自定义的,你的第二个按钮是系统的。如果你想让你的第一个成为系统。您应该 alloc
并 init
它。
If you subclass UIButton, buttonWithType: does not return an instance of your subclass. If you want to create an instance of a specific subclass, you must alloc/init the button directly.
关于ios - UIButton 的空自定义类改变了它的外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20990477/