
I would like my UILabel to appear here in the center horizontally and vertically inside the overlay And I would like to overlay the UIView (the black area with the light alpha behind the hipster lorem ipsum text) to resize to give me 10 pixels of indentation above and below, but at the same time automatically stretch its width. Can someone point me in the right direction? I want to make this as dynamic as possible.
Here is what I need to do like this:
descView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, 160)];
descView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
descView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
descLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 600, 120)];
descLabel.center = CGPointMake(self.view.bounds.size.width/2, descView.bounds.size.height/2);
descLabel.backgroundColor = [UIColor clearColor];
descLabel.opaque = NO;
descLabel.textAlignment = UITextAlignmentCenter;
descLabel.text = currentPhoto.desc;
descLabel.numberOfLines = 5;
descLabel.textColor = [UIColor whiteColor];
descLabel.autoresizingMask = UIViewAutoresizingFlexibleMargins;
CGRect frame = descLabel.frame;
frame.origin.x = (descView.frame.size.width - descLabel.frame.size.width)/2;
descLabel.frame = frame;
[self.view addSubview:descView];
[descView addSubview:descLabel];
source
share