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];
You can do this by checking the touch-start point. If it hits one of your four corners you can resize based on the distance between that touch-start point and the current-touch point. (If the touch-start point didn't hit a corner, we just move the view instead of resizing.)
sizeToFit()Resizes the receiver's frame so that it's the minimum size needed to contain its cell.
sizeToFit()Resizes and moves the receiver view so it just encloses its subviews.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With