I want to make an UILabel with a specific CGAffineTransform and an UIImageView in a UIView. So far i have tried to make random view in the self but problem is some views are being outside of the screen.Here is my code so far i have done.
-(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;
}
}
}
Now at first my question is how can make all views in the self.view which frame will be in the self.view and Secondly If i want to make UIView with specific CGAffineTransform then how i can make it?
0 comments:
Post a Comment