{"id":1143,"date":"2019-08-21T19:21:11","date_gmt":"2019-08-21T19:21:11","guid":{"rendered":"http:\/\/www.netexl.com\/blog\/?p=1143"},"modified":"2026-04-02T09:32:40","modified_gmt":"2026-04-02T09:32:40","slug":"replace-white-background-in-cordova-ios-mobile-app-with-a-hex-color-background","status":"publish","type":"post","link":"https:\/\/www.netexl.com\/blog\/replace-white-background-in-cordova-ios-mobile-app-with-a-hex-color-background\/","title":{"rendered":"Replace White Background in Cordova iOS Mobile App with a Hex Color Background"},"content":{"rendered":"\n<p>If you have gone thorugh <a href=\"https:\/\/www.netexl.com\/blog\/cordova-ios-mobile-app-displays-white-background-color-after-splash-screen\/\" target=\"_blank\" rel=\"noopener noreferrer\">this article<\/a>, we replaced white background with black background. In order to change the background color to a color of our choosing, we can use the code snippent below in MainViewController.m<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>- (void)viewDidLoad\n{\n    &#91;super viewDidLoad];\n    \/\/ Do any additional setup after loading the view from its nib.\n\tself.webView.opaque=NO;\n\tNSString *hexColor = @\"#33CCFF\";\n\tUIColor *theColor = &#91;self colorFromHexString:hexColor];\n    self.webView.backgroundColor = theColor;\n}\n\n\/\/ Assumes input like \"#FF00FF00\" (#AARRGGBB)\n- (UIColor *)colorFromHexString:(NSString *)hexString {\n    unsigned rgbValue = 0;\n    float alphaValue = 1.0;\n    NSScanner *scanner = &#91;NSScanner scannerWithString:hexString];\n    &#91;scanner setScanLocation:1]; \/\/ bypass '#' character\n    &#91;scanner scanHexInt:&amp;rgbValue];\n    if (hexString.length==9) {\n        alphaValue = ((rgbValue &amp; 0xFF000000) >> 24)\/255.0;\n    }\n    return &#91;UIColor colorWithRed:((rgbValue &amp; 0x00FF0000) >> 16)\/255.0 green:((rgbValue &amp; 0x0000FF00) >> 8)\/255.0 blue:(rgbValue &amp; 0x000000FF)\/255.0 alpha:alphaValue];\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you have gone thorugh this article, we replaced white background with black background. In order to change the background color to a color of our choosing, we can use the code snippent below in MainViewController.m<\/p>\n","protected":false},"author":5,"featured_media":1539,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,14,3,27],"tags":[],"class_list":["post-1143","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cordova","category-how-to","category-html5","category-ios"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts\/1143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/comments?post=1143"}],"version-history":[{"count":3,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts\/1143\/revisions"}],"predecessor-version":[{"id":1164,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts\/1143\/revisions\/1164"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/media\/1539"}],"wp:attachment":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/media?parent=1143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/categories?post=1143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/tags?post=1143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}