I am trying to resize a UIView instance that is part of the tapjoy SDK.
here is the code:
- (UIView*)showFeaturedAppFullScreenAd:(NSString*)adURL withFrame:(CGRect)frame
{
UIView *fullScreenAdView = nil;
[self moveViewToFront];
[self.view setAlpha:1];
fullScreenAdView = [TJCFeaturedAppViewHandler showFullScreenAdWithURL:adURL withFrame:frame];
[self.view addSubview:fullScreenAdView];
return fullScreenAdView;
}
I tried adding my own setter method in the above method:
fullScreenAdView.frame = CGRectOffset(fullScreenAdView.frame, 50, 500);
But it had no effect on the tapjoy ad when I ran it.
My question is this: I am trying to resize this instance so that instead of taking up 100% of the device window, it takes up (let's say) 70%.
I have some ideas how to do this, but they're vague (such as writing fullScreenAdView = [mainScreen * 0.7f), but I was hoping someone would have some more concrete ideas.
edit: here's a super, high-tech picture of what my situation is. http://i207.photobucket.com/albums/bb289/teh_Mac/tjAd-1.jpg
This is the proto-method I have come up with so far:
fullScreenAdView.frame = CGRectMake(0,0, [mainScreen * 0.7f], [mainScreen * 0.7f];
Why don't you use CGRectMake and make it a percentage of the superview?
float percentage = .7f; //whatever you like
int xPosition = fullScreenAdView.superview.frame.size.width * ((1 - percentage) / 2);
int yPosition = fullScreenAdView.superview.frame.size.height * ((1 - percentage) / 2);
int width = fullScreenAdView.superview.frame.size.width * (1 - percentage);
int height = fullScreenAdView.superview.frame.size.height * (1 - percentage);
fullScreenAdView.frame = CGRectMake(xPosition, yPosition, width, height);
This is written off the top of my head, but I think with a little tweaking it would do what you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.