ios - UIButton 的空自定义类改变了它的外观

标签 ios uibutton xib

我添加了 2 个 UIButtons 以在 xib 文件中查看。我已将第一个按钮的自定义类设置为 AButtonTest。这个类的实现是空的:

@implementation AButtonTest

@end

我运行 ios 6 模拟器:

enter image description here

如您所见,左侧的按钮看起来有所不同。为什么?

最佳答案

当您继承 UIButton 时,默认按钮类型是 UIButtonTypeCustom 而不是 UIButtonTypeSystem。显然你的第一个按钮是自定义的,你的第二个按钮是系统的。如果你想让你的第一个成为系统。您应该 allocinit 它。

Reference :

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/

相关文章:

ios - 上下文菜单阻止拖放到新窗口中

iphone - UIButton图像和视网膜显示

iphone - UIButton 渐变不起作用

iphone - 从 XIB 文件过渡到 Storyboard

ios - 当 IBOutlets 为零时,将自定义 View 添加到 Storyboard会崩溃

ios - 来自 Xib 文件错误的 Swift init ViewController

ios - 是否可以在 Swift 中覆盖 deinit?

iphone - 设置中的圆角矩形按钮

android - 哪种AR(增强现实)框架(Android & iOS)适合我的情况

iphone - 如何通过 UIButton 将 UITextfield 发送到变量?