我用這個代碼(在UIView類中)。如何在Objective-C中以相同寬度以編程方式在UIView上放置2個UIButton?
- (void)setup {
self.backgroundColor = [UIColor colorWithWhite:0.12f alpha:1.0f];
_doneTextButton = [UIButton buttonWithType:UIButtonTypeCustom];
_doneTextButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[_doneTextButton setTitle:@"Save" forState:UIControlStateNormal];
[_doneTextButton setTitleColor:CODE_A_COLOR forState:UIControlStateNormal];
[_doneTextButton setBackgroundColor:CODE_6_COLOR] ;
[_doneTextButton.titleLabel setFont:[FontManager getOpenSansBoldFontWithSize:16]];
[_doneTextButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_doneTextButton];
}
我得到這個輸出(按鈕在角落)。
我想這個 「取消」 和 「保存」 按鈕恰好UIView的
我使用第三方的lib同樣適合。並沒有想法直邏輯不工作。我如何設置兩個按鈕的框架?期待autoLayout代碼。提前致謝。
您使用的是自動佈局 –