我目前有下面的圖片,我試圖設置一個邊框。它由一個UIImageView
的裏面(一transparent.png
)Objective-C:在UIImage上繪製邊框
當我嘗試設置邊框爲我的圖像(見代碼),它提供了邊界到UIImage
的圖像,但它不會「卡」在我圖片。是否有可能實現這種效果?
See image current implementation here.
- (UIImage*)imageWithBorderFromImage:(UIImage*)source;
{
CGSize size = [source size];
UIGraphicsBeginImageContext(size);
CGRect rect = CGRectMake(0, 0, size.width, size.height);
[source drawInRect:rect blendMode:kCGBlendModeNormal alpha:1.0];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 0.5, 1.0, 1.0);
CGContextStrokeRect(context, rect);
UIImage *testImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return testImg;
}
看看這個:https://stackoverflow.com/questions/1354811/how-can-i-take-an-uiimage-and-give-it-a-black-border ... A很多都與普通方塊有關,但在底部有一個關於圍繞有趣(意思是不是方塊/圓圈等)圖像/形狀創建邊框的答案 – Burnie777
你是如何創建/獲取該圖像的?你自己畫了嗎? – Larme
@Larme不,這是我從資產 – iCappsCVA