【Swift】色のUIColorを16進数から取得

import UIKit

struct UIColorUtil {
static func rgb(rgbValue: UInt) -> UIColor {
return UIColor(
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
alpha: CGFloat(1.0)
)
}
}
UIColorUtil.rgb(rgbValue: 0x6FD0D8)

↓参考サイト

返信を残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA