6
A
回答
1
這不正是你問什麼,但它可能會更好,如果你只是想一個邊界(而不是實際繪製邊界到它)來顯示圖像...
您可以使用CALayer
到邊界(和圓角,陰影等)添加到任何UIView
......
// imgView is an instance of UIImageView, but this works with any UIView
imgView.layer.borderWidth = 2.0f;
imgView.layer.borderColor = [[UIColor blackColor] CGColor];
您還需要#import <QuartzCore/QuartzCore.h>
並鏈接到QuartzCore框架這個工作。
2
我們需要有CIImage範圍或我們想要創建實心邊框的CGRect。比,我們可以在指定的區域繪製一個CIImage形成一條實線,然後爲不同位置重複3次以上的步驟來繪製一個完整的實心矩形。以下是將在指定區域上方繪製直線的代碼片段。
CIImage *overlay1 = [CIImage imageWithColor:[CIColor colorWithRed:255/255.f green:0/255.f blue:0/255.f alpha:1.00f]];
overlay1 = [overlay1 imageByCroppingToRect:image.extent];
overlay1 = [overlay1 imageByApplyingFilter:@"CIPerspectiveTransformWithExtent" withInputParameters:@{@"inputExtent":[CIVector vectorWithCGRect:image.extent],@"inputTopLeft":[CIVector vectorWithCGPoint:CGPointMake(topLeft.x - 5, topLeft.y + 5)],@"inputTopRight":[CIVector vectorWithCGPoint:CGPointMake(topRight.x + 5, topRight.y + 5)],@"inputBottomLeft":[CIVector vectorWithCGPoint:CGPointMake(topLeft.x - 5, topLeft.y)],@"inputBottomRight":[CIVector vectorWithCGPoint:CGPointMake(topRight.x + 5, topRight.y) ]}];
overlay = [ overlay1 imageByCompositingOverImage:overlay];
我已經保持5像素的寬度。 topLeft,topRight ....是該職位的相應CGPoint。對於一個完整的矩形,你還需要bottomLeft和bottomRight。
覆蓋圖是原始的CIImage。
+0
不確定爲什麼你需要透視變換。爲什麼不剪切線,作爲寬度爲5倍,4倍的矩形。 – user1055568
相關問題
- 1. 圓形元素的純色邊框
- 2. 添加圓角色邊框iTextSharp的
- 3. 爲文本和顏色添加邊框
- 4. 添加左側邊框顏色編程
- 5. 添加邊框和顏色的JavaScript
- 6. 如何用matplotlib爲燭臺添加邊框或邊緣顏色?
- 7. 添加邊框
- 8. 添加邊框使用GPUImage
- 9. html添加邊框
- 10. CSS - 在剪輯路徑多邊形上添加邊框顏色
- 11. R,傳單多邊形添加黑色邊框
- 12. 使用純黑色矩形的WPF邊框
- 13. 純CSS的邊框圖像
- 14. 如何用右箭頭在div上添加白色邊框?
- 15. 使用CIImage「內部」(像邊緣)檢測?
- 16. CoreImage:使用純色創建一個CIImage並將其顯示在NSImageView中
- 17. 如何將文本添加到CIImage?
- 18. 在UIBarButtonItem中添加邊框
- 19. 向jcheckbox添加邊框
- 20. 向UIimage添加邊框
- 21. 添加邊框圖像
- 22. 添加邊框列出
- 23. 將邊框添加到flash.display.Loader
- 24. 添加邊框的div
- 25. 將邊框添加到AlertDialog
- 26. JQuery Image OnClick添加邊框
- 27. 向GridBagLayout行添加邊框
- 28. 在Java中添加邊框
- 29. jQuery的添加邊框表
- 30. 添加表格邊框
謝謝jhabbott,但它並沒有幫助我。我正在嘗試修改圖像,而不是僅在其頂部顯示邊框。 – frimoldi