Skip to content

Commit 0f118e1

Browse files
12207480tanyang
authored andcommitted
add custom property
1 parent 2d480a2 commit 0f118e1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

TYAlertControllerDemo/TYAlertController/TYAlertView.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ - (instancetype)initWithFrame:(CGRect)frame
9090

9191
[self addContentViews];
9292

93-
[self layoutContentViews];
93+
//[self layoutContentViews];
9494

9595
[self addTextLabels];
9696

97-
[self layoutTextLabels];
97+
//[self layoutTextLabels];
9898

9999
}
100100
return self;
@@ -189,10 +189,16 @@ - (void)addAction:(TYAlertAction *)action
189189
button.tag = kButtonTagOffset + _buttons.count;
190190
button.translatesAutoresizingMaskIntoConstraints = NO;
191191
[button addTarget:self action:@selector(actionButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
192+
192193
[_buttonContentView addSubview:button];
193194
[_buttons addObject:button];
194195
[_actions addObject:action];
195196

197+
if (_buttons.count == 1) {
198+
[self layoutContentViews];
199+
[self layoutTextLabels];
200+
}
201+
196202
[self layoutButtons];
197203
}
198204

@@ -253,9 +259,11 @@ - (void)layoutContentViews
253259

254260
- (void)layoutTextLabels
255261
{
262+
// title
256263
_titleLable.translatesAutoresizingMaskIntoConstraints = NO;
257264
[_textContentView addConstarintWithView:_titleLable topView:_textContentView leftView:_textContentView bottomView:nil rightView:_textContentView edageInset:UIEdgeInsetsZero];
258265

266+
// message
259267
_messageLabel.translatesAutoresizingMaskIntoConstraints = NO;
260268
[_textContentView addConstarintWithTopView:_titleLable toBottomView:_messageLabel constarint:_textLabelSpace];
261269
[_textContentView addConstarintWithView:_messageLabel topView:nil leftView:_textContentView bottomView:_textContentView rightView:_textContentView edageInset:UIEdgeInsetsZero];
@@ -265,6 +273,9 @@ - (void)layoutButtons
265273
{
266274
UIButton *button = _buttons.lastObject;
267275
if (_buttons.count == 1) {
276+
277+
278+
268279
[button addConstraintToView:_buttonContentView edageInset:UIEdgeInsetsZero];
269280
[button addConstarintWidth:0 height:_buttonHeight];
270281
}else if (_buttons.count == 2) {
@@ -284,6 +295,7 @@ - (void)layoutButtons
284295
[_buttonContentView addConstarintWithTopView:firstBtn toBottomView:secondBtn constarint:_buttonSpace];
285296

286297
}
298+
287299
UIButton *lastSecondBtn = _buttons[_buttons.count-2];
288300
[_buttonContentView removeConstraintWithView:lastSecondBtn attribte:NSLayoutAttributeBottom];
289301
[_buttonContentView addConstarintWithTopView:lastSecondBtn toBottomView:button constarint:_buttonSpace];

TYAlertControllerDemo/ViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ - (IBAction)showAlertView:(id)sender {
4343
// [alertView addAction:[TYAlertAction actionWithTitle:@"默认2" style:TYAlertActionStyleDefault handler:^(TYAlertAction *action) {
4444
//
4545
// }]];
46-
46+
//
4747
[alertView addTextFieldWithConfigurationHandler:^(UITextField *textField) {
4848

4949
}];

0 commit comments

Comments
 (0)