如何防止iOS调整xib的大小
我有一个仅用于创建UIImage的xib。换句话说,首先我得到了xib,如中所示如何防止iOS调整xib的大小,ios,iphone,xcode,uiview,uiimage,Ios,Iphone,Xcode,Uiview,Uiimage,我有一个仅用于创建UIImage的xib。换句话说,首先我得到了xib,如中所示 UIView *view =[[UINib nibWithNibName:@"MyXib" bundle:nil] instantiateWithOwner:self options:nil].firstObject; //...add content to xib 然后从xib创建一个UIImage,调用 UIImage *image = [self imageWithView:view]; 方法 - (UI
UIView *view =[[UINib nibWithNibName:@"MyXib" bundle:nil] instantiateWithOwner:self options:nil].firstObject;
//...add content to xib
然后从xib创建一个UIImage,调用
UIImage *image = [self imageWithView:view];
方法
- (UIImage *) imageWithView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
问题是,我的xib尺寸为600 x 700(自由形式)。但不管出于什么原因,iPhone/iOS正在生成一个与我的iPhone差不多大的图像。但我希望我的图像保持预设的大小600乘700。我该怎么做
现在一切正常:除了生成的图像的大小似乎是我的iPhone S5的尺寸之外