【发布时间】:2013-10-30 21:48:48
【问题描述】:
我对带有两个 UITextView 的“autoresizingMask”有疑问。当我调整两个 UITextViews 的大小时,第一个重叠在第二个之上。 我附上了一张图片来解释这个问题。
谢谢!
更新:我放了revenant代码
[UIView]
self.autoresizesSubviews = YES;
// Configure title label
_titleLabel = [[UILabel alloc] init];
_titleLabel.frame = CGRectMake(4.0, 4.0, self.bounds.size.width - 8.0, 33.0);
_titleLabel.backgroundColor = APP_COLOR(1.0);
_titleLabel.font = FONT_LATO_BOLD(18.0);
_titleLabel.textColor = [UIColor whiteColor];
_titleLabel.textAlignment = UITextAlignmentCenter;
[self addSubview:_titleLabel];
// Question textView
_questionTextView = [[UITextView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(_titleLabel.bounds), (usableHeight / 2.0) - 4.0)];
_questionTextView.layer.cornerRadius = 8.0;
_questionTextView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
[self addSubview:_questionTextView];
// Answer textView
_answerTextView = [[UITextView alloc] initWithFrame:CGRectMake(CGRectGetMinX(_questionTextView.frame), CGRectGetMaxY(_questionTextView.frame) + 8.0, CGRectGetWidth(_questionTextView.bounds), (usableHeight / 2.0) - 4.0)];
_answerTextView.layer.cornerRadius = 8.0;
_answerTextView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin;
[self addSubview:_answerTextView];
【问题讨论】:
-
如果没有更多关于如何设置蒙版以及如何调整视图大小的详细信息,将很难提供帮助。使用相关代码更新您的问题。
-
rmaddy,我更新了答案。谢谢!
标签: ios resize uitextview overlap autoresizingmask