我的應用程序可以有許多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. CGRectMake爲iPhone 5和iPhone 4
- 2. 我是否需要爲iPhone 4和iPhone 5設置單獨的圖像?
- 3. UITabBar和UITabBarItem與特定的圖像@ 2x的iPhone 5和iPhone 6
- 4. iPhone 5,iPhone 6圖像尺寸
- 5. 圖像不能顯示在iOS 9 iPhone 4和5
- 6. 從iPhone 5+壓縮iPhone 4/4s的UI
- 7. Xcode - Interface Builder和iPhone 5圖像
- 8. 將iphone 4應用轉換爲iphone 5
- 9. 如何讓圖像調整爲4英寸的iPhone 5
- 10. #define適用於不同的屏幕尺寸 - iPhone 4和iPhone 5
- 11. 我如何將iPhone 4動態圖像更改爲iPhone 5屏幕
- 12. 使媒體查詢兼容iPhone 4和iPhone 5
- 13. IPHONE 4和IPHONE 5媒體查詢引導
- 14. iPhone 5和iPhone 4用戶界面問題
- 15. 在一個應用程序中爲iPhone 4和iPhone 5開發
- 16. HTML 5視頻在iPhone的圖像幀
- 17. 圖像分辨率爲iPhone 6/6秒和5/5秒
- 18. iPhone 4圖像分辨率和圖像尺寸
- 19. iPhone 4上的圖像瓷磚
- 20. iPhone 4和iPhone 5的應用程序支持iPhone 6和iPhone 6加號或不加號
- 21. iPhone 4s和iPhone 5的兼容性
- 22. 模糊像素的iPhone 4
- 23. iphone 4 - 加載圖像X舊設備
- 24. iphone 4圖像丟失分辨率
- 25. IPhone 4圖像本地與服務器?
- 26. iphone 4高分辨率啓動圖像
- 27. iPhone 4 - 高分辨率圖像模糊
- 28. iPhone 4 - TabBar圖標
- 29. 的UIButton沒有可觸 - 自定義從iPhone 4到iPhone 5
- 30. 從iPhone 4到iPhone 5的屏幕尺寸兼容性問題