我的应用程序可以有许多images
为background
。这images
我需要下载,所以我不想单独下载iPhone 4和iPhone 5。我使用方法self.view.backgroundcolor = [UIColor colorWithPatternImage:[UIImage imagenamed:@"myImage.jpg"]]
。我想下载一个image
为iPhone 5,然后切割顶部和底部的边界,以便与iPhone 4一起使用。我怎样才能以最好的方式编程。哦,也许有我的问题最好的解决方案?Iphone 4和iPhone 5的图像
0
A
回答
1
您可以使用此功能裁剪图像定义您想要的矩形,因为剩余的图像将被删除 为此,您需要CoreGraphics.framework
,所以不要忘记添加到您的项目中。
- (UIImage *)imageByCroppingtoRect:(CGRect)rect fromImage:(UIImage *)image
{
CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], rect);
UIImage *cropped = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return cropped;
}
1
试试这个
- (UIImage *)cropImage:(UIImage *)oldImage {
CGSize imageSize = oldImage.size;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(imageSize.width,imageSize.height - 100),NO,0.); // this height you want to change
[oldImage drawAtPoint:CGPointMake(0, -46) blendMode:kCGBlendModeCopy alpha:1.];// from top to change X is never change
UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return croppedImage;
}
相关问题
- 1. 支持iPhone 3G,iPhone 4和iPhone 5的图像分辨率
- 2. 做的iPhone 5和iPhone 4
- 3. CGRectMake为iPhone 5和iPhone 4
- 4. 图片为iPhone 4和5
- 5. 在iphone 4和iphone 5模拟器上不能缩放图像
- 6. UIView Iphone 4和Iphone 5中的问题
- 7. iPhone 5和iPhone 4的屏幕问题
- 8. 微分在iPhone 4,iPhone 5和iPad
- 9. iPhone 4和iPhone 5上不同的地图缩放比例
- 10. 我是否需要为iPhone 4和iPhone 5设置单独的图像?
- 11. 在故事板中更改iphone 4和iphone 5之间的背景图像?
- 12. 为Iphone 3g,Iphone 4s和Iphone 5设置背景图像
- 13. UITabBar和UITabBarItem与特定的图像@ 2x的iPhone 5和iPhone 6
- 14. iPhone 5,iPhone 6图像尺寸
- 15. 从iPhone 5+压缩iPhone 4/4s的UI
- 16. 图像不能显示在iOS 9 iPhone 4和5
- 17. iPhone 5图像序列号
- 18. iPhone 5 - 背景图像
- 19. Xcode - Interface Builder和iPhone 5图像
- 20. iphone 5和4的故事板布局
- 21. 将iphone 4应用转换为iphone 5
- 22. 响应式菜单(iphone 4到iphone 5)
- 23. 自动布局是否适合iPhone 5和iPhone 4的背景?
- 24. 兼容性问题的iPhone 4和iPhone 5
- 25. #define适用于不同的屏幕尺寸 - iPhone 4和iPhone 5
- 26. iPhone 4和iPhone 5的相机覆盖高度
- 27. 如何设置按钮的框架对于iPhone 4和iPhone 5
- 28. 如何在Iphone 4和Iphone 5中显示不同的UIImage?
- 29. 如何在ios6中设置iphone 4和iphone 5的框架
- 30. 如何让图像调整为4英寸的iPhone 5