1
Swift에서 여러 UIBezierPaths 배열로 UIImage를 만들고 싶습니다.Swift에서 Uibezierpath Array에서 UIImage 만들기
func convertPathsToImage(paths: [UIBezierPath]) -> UIImage{
let imageWidth: CGFloat = 200
let imageHeight: CGFloat = 200
let colorSpace:CGColorSpace = CGColorSpaceCreateDeviceRGB()!
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue)
let context = CGBitmapContextCreate(nil, Int(imageWidth), Int(imageHeight), 8, 0, colorSpace, bitmapInfo.rawValue)
CGContextBeginPath(context);
UIColor.blackColor().set()
for path in paths{
path.stroke()
}
let newImageRef = CGBitmapContextCreateImage(context);
let newImage = UIImage(CGImage: newImageRef!)
return newImage
}
4. 결과 빈 이미지 :
나는 다음 코드를 시도했다.누군가 내가 뭘 잘못하고 있는지 설명 할 수 있습니까? 고마워요!
이러한 경로를보기의 레이어에 추가하고 있습니까? – EridB
@EridB 아니요.보기 레이어에 추가하고 싶지 않습니다. –
'[UIBezierPath]'배열의 구체적인 예를 붙일 수 있습니까? –