스타와 같은 이미지 패턴을 그리려는 경우, 그 색상을 변경할 수 있습니다. 이미지보기를 사용하지 않고 이미지 자체의 색상을 변경할 수 있습니까? 나는 당신의 이미지가있는 UIView에서와 같이, 그것은 오래하는 UIView
의 한 속성입니다있는 UIImageView의 색조 색상을 변경 많은 답을 보았지만, 효과는 UIImageView
의뿐만 아니라 속성입니다있는 UIImageswift3에서 Uiimageview를 사용하지 않고 UIImage 색상을 변경하십시오.
0
A
답변
0
해답을 찾아 주셔서 감사합니다. 그러나 해결책을 얻었습니다.
func changePatternImageColor() {
patternImage = UIImage(named: "pattern_star.png")! //make sure to reinitialize the original image here every time you change the color
UIGraphicsBeginImageContext(patternImage.size)
let context = UIGraphicsGetCurrentContext()
let color = UIColor(red: self.red, green: self.green, blue: self.blue, alpha: self.opacity)
color.setFill()
context?.translateBy(x: 0, y: patternImage.size.height)
context?.scaleBy(x: 1.0, y: -1.0)
//set the blend mode to color burn, and the original image
context?.setBlendMode(CGBlendMode.exclusion) //this does the magic.
let rect = CGRect(x: 0, y: 0, width: patternImage.size.height, height: patternImage.size.height)
context?.draw(patternImage.cgImage!, in: rect)
//set the mask that matches the shape of the image, then draw color burn a colored rectangle
context?.clip(to: rect, mask: patternImage.cgImage!)
context?.addRect(rect)
context?.drawPath(using: CGPathDrawingMode.fill)
patternImage = UIGraphicsGetImageFromCurrentImageContext()!
image_ref = patternImage.cgImage
UIGraphicsEndImageContext()
}
patternImage는 자산에 추가 된 이미지입니다. 오후 8시 30 분 P.S. patternImage는
0
관련 문제
- 1. UIImageView를 anotherVIewController에서 변경하십시오.
- 2. UIImageView 또는 UIImage 너비를 변경하십시오.
- 3. 데이터베이스를 사용하지 않고 gridview를 변경하십시오.
- 4. 컨트롤 색상을 사용하지 않을 때 변경하십시오.
- 5. 클릭하지 않고 JTable 셀 색상을 변경하십시오.
- 6. 텍스처를 손상시키지 않고 오브젝트의 색상을 변경하십시오.
- 7. 클래스를 변경하지 않고 버튼의 색상을 변경하십시오.
- 8. 핀 색상을 MKAnnotation 객체에서 변경하십시오.
- 9. System.Drawing을 사용하지 않고 색상을 생성하는 방법
- 10. 기본 색상을 사용하지 않고 CCSprite 채색
- 11. WinForms를 사용하지 않고 DataVisualization.Chart 크기를 변경하십시오.
- 12. mysql을 사용하지 않고 웹 사이트의 내용을 변경하십시오.
- 13. drawRect를 사용하지 않고 UIButton rect를 변경하십시오.
- 14. XML을 사용하지 않고 확인란 크기를 변경하십시오.
- 15. 경로 컨트롤러를 사용하지 않고 페이지 URL을 변경하십시오.
- 16. mouseup/mousedown을 사용하지 않고 선택된 요소를 변경하십시오.
- 17. 마스킹은 UIImage-iOS의 색상을 변경합니다.
- 18. 애니메이션을 사용하지 않고 커브 UIView/UIImageView를 만들 수 있습니까?
- 19. 캔버스, Tkinter, Python의 픽셀 색상을 변경하십시오.
- 20. Swift의 tableView에서 이미지 색상을 변경하십시오. 3
- 21. 어떻게 다른 UIImageView를 가리 키도록 UIImageView를 설정합니까
- 22. Tint UIImage 다시 그리기하지 않고
- 23. CSS를 사용하지 않고 텍스트를 변경하지 않고 입력을 대문자로 변경하십시오.
- 24. Android에서 사용하지 않도록 설정 한 체크 박스의 색상을 변경하십시오.
- 25. 큐브의 얼굴 색상을 변경하십시오.
- 26. AUTOHOTKEY WS_EX_CLIENTEDGE 색상을 변경하십시오.
- 27. UISplitView에서 RootViewController의 색상을 변경하십시오.
- 28. matlab에있는 이미지의 색상을 변경하십시오.
- 29. Listview에서 Textview의 색상을 변경하십시오.
- 30. glBufferSubData를 사용하여 색상을 변경하십시오.
당신이의 –
가능한 중복 무엇을하려고 몇 가지 코드를 제공 할 수 검은 색에 있어야 자산 에 추가 [A있는 UIImage에하려면 tintColor을 적용하는 방법?] (http://stackoverflow.com/questions/19802982/tintcolor-to-a-ui 이미지) – inokey
아래에 게시 된 솔루션을 찾았습니다 – Van