ios - 使用 PureLayout 自定义 UIButton

标签 ios objective-c iphone uibutton autolayout

我正在使用 SmileyBorgPureLayout一些自动布局魔法的库。

如何添加 UIButtonTypeCustom

普通按钮将使用以下纯布局 UIButton 类方法初始化:

self.myButton = [UIButton newAutoLayoutView];

自定义 UIButtons 初始化为

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

因为我不能做类似的事情

self.myButton = [[UIButton buttonWithType:UIButtonTypeCustom] newAutoLayoutView];

并且没有“buttonType”属性来设置后初始化 - 我该如何结合 在 PureLayout 中创建自定义 UIButton 的这些步骤?

最佳答案

UIButton 默认为 UIButtonTypeCustom,因此您将能够使用:

self.myButton = [UIButton newAutoLayoutView];

为了好玩,我建议你使用 NSLog/printf self.myButton.buttonType!

关于ios - 使用 PureLayout 自定义 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25849248/

相关文章:

iphone - MKReverseGeocoder "deprecated in iOS 5"

iphone - 当手绕传感器移动时,接近传感器打开

iphone - 为什么我无法在 iPhone SDK 中访问 CALayer 的visibleRect 属性?

ios - 在 Xcode 中通过 CocoaPods 安装 Soundcloud API 后获取编译错误和警告

android - Flutter - 在 GridView 的末尾添加一个按钮

ios - 不响应手势 UITableVIew editActionsForRow

ios - 使用 ARKit 拍摄高质量照片

objective-c - 如何在枚举期间删除 NSMutableArray 或 NSMutableDictionary 中的元素?

ios - 如何在ios7中获取当前高度

iphone - 如何动态变换图像的大小?