EEYatHo 앱 깎는 이야기

Swift ) UIColor로 UIImage만들기, DynamicUIImage만들기 - EEYatHo iOS 본문

iOS, Swift

Swift ) UIColor로 UIImage만들기, DynamicUIImage만들기 - EEYatHo iOS

EEYatHo 2021. 12. 6. 18:07
반응형

UIColor -> UIImage

UIGraphicsBeginImageContext(CGSize(width: 1, height: 1))
UIGraphicsGetCurrentContext()!.setFillColor(uicolor.cgColor)
UIGraphicsGetCurrentContext()!.fill(CGRect(x: 0, y: 0, width: 1, height: 1))
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

 

 


 

UIImage + UIImage -> DynamicUIImage

( 다크모드, 라이트모드에 따라 런타임에 바뀌는 Image )

lightImage?.imageAsset?.register(darkImage ?? UIImage(), with: .init(userInterfaceStyle: .dark))
Comments