开发者

resizing view in universal application

i am making my application universal, but i am having a small problem with resizing my background image. Here's my code

开发者_开发百科 UIImageView *myImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dubstep2.jpg"]];
[self.view addSubview:myImage];
UIScreen *screen = [UIScreen mainScreen];
[myImage setFrame:[screen applicationFrame]];
[myImage release];

I am putting this in viewDidLoad. The image resizes, but it does not resize "correctly" simply because i have a tabBar. So a portion of the view is hidden, and it leaves a small gap at the top. I need this view to shift up when it resizes. I have tried adding an image view in interface builder and assigning the image to that, and then adjusting it in IB but it still does not shift.


It is not entirely clear as to whether you are using a UITabBar object or UITabBarController. It is most likely to be a UITabBarController, so I shall assume that the code presented is from one of your view controllers. In such case, you shall have to do this –

UIImageView * myImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dubstep2.jpg"]];
myImage.frame = self.view.bounds;
myImage.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; // This will make sure that `myImage` is latched onto its parent view's edges.

[self.view addSubview:myImage];
[myImage release];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜