This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"response_code": "200", | |
"response_status": "success", | |
"response_message": "", | |
"id": "67", | |
"sku": "MH01", | |
"name": "Chaz Kangeroo Hoodie", | |
"type": "configurable", | |
"regular_price": "52", | |
"discounted_price": "0", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. | |
// Instantiate a view object | |
let view = UIView() | |
// 2. | |
// Set translatesAutoresizingMaskIntoConstraints property to false to | |
// explicitly applying constraints to the view |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. | |
// Instantiate a view object | |
let view = UIView() | |
// 2. | |
// Set translatesAutoresizingMaskIntoConstraints property to false to | |
// explicitly applying constraints to the view | |
view.translatesAutoresizingMaskIntoConstraints = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Instantiate a label and a textfield | |
let firstNameLabel = UILabel() | |
firstNameLabel.text = "First" | |
firstNameLabel.translatesAutoresizingMaskIntoConstraints = false | |
self.view.addSubview(firstNameLabel) | |
let firstNameTextField = UITextField() | |
firstNameTextField.borderStyle = .roundedRect |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Method that returns a single row of a chessboard | |
func getRow(of length: Int, for rowNo: Int) -> UIView { | |
let containerView = UIView() | |
var previousTile: UIView? | |
for i in 0...length { | |
// Instantiate a tile view and add it to container | |
let tile = UIView() | |
tile.translatesAutoresizingMaskIntoConstraints = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Method that returns a single row of a chessboard | |
func getRow(of length: Int, for rowNo: Int) -> UIView { | |
let containerView = UIView() | |
var previousTile: UIView? | |
for i in 0...length { | |
// Instantiate a tile view and add it to container | |
let tile = UIView() | |
tile.translatesAutoresizingMaskIntoConstraints = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Instantiate the UILayoutGuide instance and give it an identifier | |
// Note: 'UI' prefix in identifier is fixed for guides created by UIKit. | |
let guide = UILayoutGuide() | |
guide.identifier = "layoutguide" | |
// 2. Add the guide to the view just like we add a subview | |
// to its parent view. | |
self.view.addLayoutGuide(guide) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pinning with the top layout guide | |
topView.topAnchor.constraint(equalTo: self.topLayoutGuide.bottomAnchor).isActive = true | |
// Pinning with the bottom layout guide | |
bottomView.bottomAnchor.constraint(equalTo: self.bottomLayoutGuide.topAnchor).isActive = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Instantiate 3 buttons, set their titles and set | |
// translatesAutoresizingMaskIntoConstraints property to false. | |
// Also add them to the superview. | |
let saveButton = UIButton(type: .roundedRect) | |
saveButton.setTitle("Save", for: .normal) | |
saveButton.translatesAutoresizingMaskIntoConstraints = false | |
self.view.addSubview(saveButton) | |
let revertButton = UIButton(type: .roundedRect) |
OlderNewer