@@ -90,11 +90,11 @@ - (instancetype)initWithFrame:(CGRect)frame
90
90
91
91
[self addContentViews ];
92
92
93
- [self layoutContentViews ];
93
+ // [self layoutContentViews];
94
94
95
95
[self addTextLabels ];
96
96
97
- [self layoutTextLabels ];
97
+ // [self layoutTextLabels];
98
98
99
99
}
100
100
return self;
@@ -189,10 +189,16 @@ - (void)addAction:(TYAlertAction *)action
189
189
button.tag = kButtonTagOffset + _buttons.count ;
190
190
button.translatesAutoresizingMaskIntoConstraints = NO ;
191
191
[button addTarget: self action: @selector (actionButtonClicked: ) forControlEvents: UIControlEventTouchUpInside];
192
+
192
193
[_buttonContentView addSubview: button];
193
194
[_buttons addObject: button];
194
195
[_actions addObject: action];
195
196
197
+ if (_buttons.count == 1 ) {
198
+ [self layoutContentViews ];
199
+ [self layoutTextLabels ];
200
+ }
201
+
196
202
[self layoutButtons ];
197
203
}
198
204
@@ -253,9 +259,11 @@ - (void)layoutContentViews
253
259
254
260
- (void )layoutTextLabels
255
261
{
262
+ // title
256
263
_titleLable.translatesAutoresizingMaskIntoConstraints = NO ;
257
264
[_textContentView addConstarintWithView: _titleLable topView: _textContentView leftView: _textContentView bottomView: nil rightView: _textContentView edageInset: UIEdgeInsetsZero];
258
265
266
+ // message
259
267
_messageLabel.translatesAutoresizingMaskIntoConstraints = NO ;
260
268
[_textContentView addConstarintWithTopView: _titleLable toBottomView: _messageLabel constarint: _textLabelSpace];
261
269
[_textContentView addConstarintWithView: _messageLabel topView: nil leftView: _textContentView bottomView: _textContentView rightView: _textContentView edageInset: UIEdgeInsetsZero];
@@ -265,6 +273,9 @@ - (void)layoutButtons
265
273
{
266
274
UIButton *button = _buttons.lastObject ;
267
275
if (_buttons.count == 1 ) {
276
+
277
+
278
+
268
279
[button addConstraintToView: _buttonContentView edageInset: UIEdgeInsetsZero];
269
280
[button addConstarintWidth: 0 height: _buttonHeight];
270
281
}else if (_buttons.count == 2 ) {
@@ -284,6 +295,7 @@ - (void)layoutButtons
284
295
[_buttonContentView addConstarintWithTopView: firstBtn toBottomView: secondBtn constarint: _buttonSpace];
285
296
286
297
}
298
+
287
299
UIButton *lastSecondBtn = _buttons[_buttons.count-2 ];
288
300
[_buttonContentView removeConstraintWithView: lastSecondBtn attribte: NSLayoutAttributeBottom];
289
301
[_buttonContentView addConstarintWithTopView: lastSecondBtn toBottomView: button constarint: _buttonSpace];
0 commit comments