Reputation: 491
At this moment, my program looks like this:
As you can see, the square with the rounded rectangles is an image but it doesn't show very well and am not sure how to solve this... Here is the class: http://pastebin.com/QPXbG1uK The background window gets added here:
UIImageView* background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"popupWindowBack.png"]] ;
background.center = CGPointMake(_bigPanelView.frame.size.width/2, _bigPanelView.frame.size.height/2);
[_bigPanelView addSubview: background];
Also what do I need to change if I want a simple view as the background instead of the image?
Upvotes: 0
Views: 598
Reputation: 4762
In Your place I would stop using Center coordinates and specifically set it's frame rectangle:
background.contentMode = UIViewContentModeScaleAspectFit;
background.frame = CGRectMake(10,10,_bigPanelView.frame.size.width-20, _bigPanelView.frame.size.height-20);
In this case - imageview will be 10 pix from top/left/right/bottom.
Remove this:
background.center = CGPointMake(_bigPanelView.frame.size.width/2, _bigPanelView.frame.size.height/2);
Upvotes: 3
Reputation: 3310
i think your image size is larger then bigPanelView view . plz set the background frame size of the bigPanelView. like
background.frame = bigPanelView.view.frame;
Upvotes: 1
Reputation: 1433
If you want to achieve your image fit your UIImageView try this:
background.contentMode = UIViewContentModeScaleAspectFit;
Also you need to set background
frame to fit screen size, for example if you adding UIImageView in UIViewController class instance:
background.frame = self.view.frame;
Upvotes: 2