【发布时间】:2015-02-23 09:04:49
【问题描述】:
我想在 UIView 中制作具有特定 CGAffineTransform 和 UIImageView 的 UILabel。到目前为止,我已经尝试在自我中进行随机视图,但问题是一些视图在屏幕之外。这是我到目前为止完成的代码。
-(void)generateView {
float viewWidth = self.view.frame.size.width;
float viewHeight = self.view.frame.size.height;
int numViews = 0;
while (numViews < 2) {
BOOL goodView = YES;
UIView *candidateView = [[UIView alloc] initWithFrame:CGRectMake(arc4random() % (int)viewWidth, arc4random() % (int)viewHeight, 200, 100)];
candidateView.backgroundColor = [UIColor redColor];
for (UIView *placedView in self.view.subviews) {
if (CGRectIntersectsRect(CGRectInset(candidateView.frame, -10, -10), placedView.frame)) {
goodView = NO;
break;
}
}
if (goodView) {
[self.view addSubview:candidateView];
numViews += 1;
}
}
}
现在首先我的问题是如何让 self.view 中的所有视图在 self.view 中出现哪个框架,其次如果我想用特定的 CGAffineTransform 制作 UIView 那么我该怎么做呢?
【问题讨论】:
标签: ios objective-c iphone uiview