我正在尝试调整属于tapjoy SDK的UIView实例的大小.
这是代码:
- (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; }
fullScreenAdView.frame = CGRectOffset(fullScreenAdView.frame,50,500);
但是当我运行它时,它对tapjoy广告没有任何影响.
我的问题是:我正在尝试调整此实例的大小,以便不占用100%的设备窗口,而是占用(比方说)70%.
我有一些想法如何做到这一点,但它们是模糊的(比如写fullScreenAdView = [mainScreen * 0.7f),但我希望有人会有更具体的想法.
编辑:这是我的情况的超级高科技图片.
http://i207.photobucket.com/albums/bb289/teh_Mac/tjAd-1.jpg
这是我到目前为止提出的原型方法:
fullScreenAdView.frame = CGRectMake(0,[mainScreen * 0.7f],[mainScreen * 0.7f];
解决方法
为什么不使用CGRectMake并将其作为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);
这是我的头脑,但我想稍微调整它会做你想要的.