{"id":47,"date":"2021-09-17T15:23:55","date_gmt":"1970-01-01T00:00:00","guid":{"rendered":"http:\/\/swift.tecc0.com\/?p=47"},"modified":"2021-09-17T15:23:55","modified_gmt":"1970-01-01T00:00:00","slug":"post-47","status":"publish","type":"post","link":"https:\/\/swift.tecc0.com\/?p=47","title":{"rendered":"Swift\u3067UIColor\u3092HEX\u5024(16\u9032\u6cd5)\u3067\u6307\u5b9a\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u8272\u306e\u8868\u73fe\u306e\u4ed5\u65b9\u306f\u3044\u308d\u3044\u308d\u3042\u308b\u3001\u6709\u540d\u306a\u8272\u3060\u3063\u305f\u3089\u3001\u76f4\u63a5\u8272\u306e\u540d\u524d\u6253\u3063\u305f\u308a\u3001RGB\u3067\u6307\u5b9a\u3057\u305f\u308a\u3001HEX\u3067\u6307\u5b9a\u3057\u305f\u308a\u3002<\/p>\n<p>Android\u3084\u3063\u3066\u305f\u308a\u3001css\u3068\u304b\u3067\u3082HEX\u304c\u5272\u3068\u30e1\u30b8\u30e3\u30fc\u3060(\u3068\u601d\u3046<\/p>\n<p>&nbsp;<\/p>\n<h2>UIColor\u3092HEX\u5024\u3067\u6307\u5b9a\u3059\u308b\u62e1\u5f35\u30b3\u30fc\u30c9<\/h2>\n<pre class=\"toolbar-overlay:false lang:swift decode:true\">extension UIColor {\r\n    class func hex (var hexStr : NSString, var alpha : CGFloat) -&gt; UIColor {\r\n        hexStr = hexStr.stringByReplacingOccurrencesOfString(\"#\", withString: \"\")\r\n        let scanner = NSScanner(string: hexStr as String)\r\n        var color: UInt32 = 0\r\n        if scanner.scanHexInt(&amp;color) {\r\n            let r = CGFloat((color &amp; 0xFF0000) &gt;&gt; 16) \/ 255.0\r\n            let g = CGFloat((color &amp; 0x00FF00) &gt;&gt; 8) \/ 255.0\r\n            let b = CGFloat(color &amp; 0x0000FF) \/ 255.0\r\n            return UIColor(red:r,green:g,blue:b,alpha:alpha)\r\n        } else {\r\n            print(\"\u4e0d\u6b63\u306a\u5024\u3060\u3088\")\r\n            return UIColor.whiteColor();\r\n        }\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u306e\u546a\u6587\u3092\u8ffd\u52a0\u3057\u3066\u3084\u308c\u3070\u304a\uff4b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>\u547c\u3073\u51fa\u3059\u3068\u304d<\/h3>\n<pre class=\"toolbar-overlay:false lang:default decode:true \">UIColor.hex(\"2c3e50\", alpha: 1)<\/pre>\n<p>&nbsp;<\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u547c\u3073\u51fa\u305b\u308b(\u30ab\u30f3\u30bf\u30f3\u3060\u306d\uff01<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e00\u5ea6\u3001\u62e1\u5f35\u3057\u3066\u304a\u3051\u3070\u4f55\u56de\u3067\u3082\u3053\u308c\u3067\u547c\u3073\u51fa\u305b\u308b\u306e\u3067\u3001\u8272\u8907\u6570\u4f7f\u3046\u3068\u304d\u306f\u4fbf\u5229\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8272\u306e\u8868\u73fe\u306e\u4ed5\u65b9\u306f\u3044\u308d\u3044\u308d\u3042\u308b\u3001\u6709\u540d\u306a\u8272\u3060\u3063\u305f\u3089\u3001\u76f4\u63a5\u8272\u306e\u540d\u524d\u6253\u3063\u305f\u308a\u3001RGB\u3067\u6307\u5b9a\u3057\u305f\u308a\u3001HEX\u3067\u6307\u5b9a\u3057\u305f\u308a\u3002 Android\u3084\u3063\u3066\u305f\u308a\u3001css\u3068\u304b\u3067\u3082HEX\u304c\u5272\u3068\u30e1\u30b8\u30e3\u30fc\u3060(\u3068\u601d\u3046 &nbsp; UIColor\u3092HEX&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/47"}],"collection":[{"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=47"}],"version-history":[{"count":2,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/47\/revisions"}],"predecessor-version":[{"id":50,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/47\/revisions\/50"}],"wp:attachment":[{"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}