【发布时间】:2015-12-26 14:39:21
【问题描述】:
所以我正在使用这个自定义 UIButton 类:https://github.com/victorBaro/VBFPopFlatButton
并且在文档中,作者使用了这个例子。
//Example
self.flatRoundedButton = [[VBFPopFlatButton alloc]initWithFrame:CGRectMake(100, 150, 30, 30)
buttonType:buttonMenuType
buttonStyle:buttonRoundedStyle
animateToInitialState:YES];
self.flatRoundedButton.roundBackgroundColor = [UIColor whiteColor];
self.flatRoundedButton.lineThickness = 2;
self.flatRoundedButton.tintColor = [UIColor flatPeterRiverColor];
[self.flatRoundedButton addTarget:self
action:@selector(flatRoundedButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.flatRoundedButton];
由于buttonType 是一个只能获取的属性,我不能只创建一个VBFPopFlatButton 实例然后分配类型,即我必须在创建实例时分配类型。我只是想知道是否有一种方法可以在无需显式设置框架的情况下进行初始化(使用CGRectMake),因为我想稍后使用约束来设置按钮的框架。
或
如果有办法在初始化之后覆盖CGRectMake?
【问题讨论】:
-
我认为您需要更改 VBFPopFlatButton 的实现
-
据我了解,你想改变原点(x和y),大小(高度和宽度)吗?
-
是的,所以根据文档和实现,我必须在初始化
VBFPopFlatButton时设置框架。我稍后添加的约束似乎确实会影响按钮的原点和大小,但看起来像CGRectMake并且约束相互干扰。
标签: ios objective-c uibutton