IOS TOPICS

IOS Introduction
Swift UI Label
Swift UI Button
Swift UI Text Field
Swift UI Slider
Swift UI Switch
Swift UI Stepper
Swift UI Date Picker
Swift UI Segmented Control
Views
Table View
Collection Views
SCROLL VIEW
iOS Content View
iOS View Controllers
iOS Bar interface
iOS Navigation interface
iOS Architect Pattern
iOS Libraries
iOS Web request and parsing
iOS user defaults
iOS Coredata and database

Customising view


Customising view

Transparency: To alter the transparency of a view use

code:

< view name > .alpha = < transparency in decimals >

Example: Setting the newView to 70% transparency (effect cascades to subview newView2)

Code:

view.backgroundColor = colorLiteral(red: 0.1019607857, green: 0.2784313858, blue: 0.400000006, alpha: 1) //use colorliteral to get a variety of color options let newView = UIView(frame: CGRect(x: 10, y: 100, width: 300, height: 50)) newView.clipsToBounds = true newView.alpha = 0.7 let newView2 = UIView(frame: CGRect(x: 6, y: 6, width: 400, height: 100)) newView.backgroundColor = UIColor.white newView2.backgroundColor = UIColor.black view.addSubview(newView) newView.addSubview(newView2)

Output:

ios output

To hide a view

Use: < view name.isHidden = True

Code:

view.backgroundColor = colorLiteral(red: 0.1019607857, green: 0.2784313858, blue: 0.400000006, alpha: 1) //use colorliteral to get a variety of color options let newView = UIView(frame: CGRect(x: 10, y: 100, width: 300, height: 50)) newView.clipsToBounds = true let newView2 = UIView(frame: CGRect(x: 6, y: 6, width: 400, height: 100)) newView.backgroundColor = UIColor.white newView2.backgroundColor = UIColor.black view.addSubview(newView) newView.addSubview(newView2) newView2.isHidden = true

Output:

ios output