Last active
October 14, 2023 15:23
-
-
Save jershell/630dc24fd7e557b3fec092375f12e97e to your computer and use it in GitHub Desktop.
compose Color to UIColor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.graphics.toArgb | |
import platform.UIKit.UIColor | |
fun Color.toUIColor(): UIColor { | |
val argb = this.toArgb() | |
val blue = argb and 0xff; | |
val green = argb shr 8 and 0xff; | |
val red = argb shr 16 and 0xff; | |
val alpha = argb shr 24 and 0xff; | |
return UIColor( | |
red = red /255.0, | |
green = green / 255.0, | |
blue = blue / 255.0, | |
alpha = alpha / 255.0 | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment