How to change background view color partialy in ios swift

user1837779

New to swift i want my background view 80% height to be red and rest in blue. Currently i'm doing that adding two views. I think there is a direct way to do that. Any guidance or help will be appreciated.

user1837779

Thanks for help. I think i found a solution.Adding a sublayer does the trick.

self.view.backgroundColor = UIColor.red
let bottomBorder = CALayer()
let t = CGRect(x: 0.0, y: (self.view.frame.size.height/100.0)*80, width: self.view.frame.size.width, height: (self.view.frame.size.height/100.0)*20)
bottomBorder.frame = t
bottomBorder.backgroundColor = UIColor.blue.cgColor
self.view.layer.addSublayer(bottomBorder)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

iOS Swift - How to change background color of Table View?

Change the background color of a Navigation View in Swift 5

Swift iOS Background Color View animation as Timer

How to use animatorSet to change background color of a View

How to change AlertDialog view background color?

Change custom text field background color and text color IOS Swift

How to change background color of UiSearchBar to black -SWIFT

How to change programmatically the background color of in tvOS in Swift?

How to change the webview background color with phonegap on iOS

How to change keyboard background color in iOS?

How to change background color of UILocalizedIndexedCollation in ios 7

Change Background Color of ViewController Swift? (Single View Application)

Background color change on table view cell tap in IOS

How to change background/color of the drawable set as background of a view?

How to change the background color of UITableViewController to gradient color on swift 3

Background color not change TextEditor view

Gradually change background color in Swift

How to change the background color

How to change the background color of a view from a different activity in android?

How to get and change drawable background color in custom view

How to change UIWindow background color through a view controller

How to change Background Color of a View containing a List back to White in SwiftUI

How to change the background color of selected expandable table view cell

How to change the background color of tree-view in kivy python?

Swift 2.2 How to change background color of tab bar controller

How to change the background color of navigation bar programmatically in Swift 5?

How do I change the background color of a tabbed page in Xamarin iOS?

How to change the background color of a Button inside a webview in iOS

How can I change the background color of a UIBarButtonItem on iOS 7+?

TOP Ranking

HotTag

Archive