Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift func for constraint

//https://stackoverflow.com/a/26181982/13171606
//open link for further info
override func viewDidLoad() {
    let newView = UIView()
    newView.backgroundColor = UIColor.red
    view.addSubview(newView)
    
    newView.translatesAutoresizingMaskIntoConstraints = false
    newView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
    newView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
    newView.widthAnchor.constraint(equalToConstant: 100).isActive = true
    newView.heightAnchor.constraint(equalToConstant: 100).isActive = true
}
Comment

swift constraints


 - firstView.coverWholeSuperview()
 - firstView.constraints(size: CGSize(width: 44, height: 44), centerX: view.centerXAnchor, centerY: view.centerXAnchor)
 - firstView.constraints(top: view.topAnchor, 
                         leading: secondView.leadingAnchor, 
                         bottom: view.bottomAnchor, 
                         trailing: secondView.trailingAnchor, 
                         padding: UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12))

Comment

PREVIOUS NEXT
Code Example
Swift :: swift pop to specific view controller 
Swift :: playing a sound in swift 
Swift :: remove child from firebase swift 
Swift :: swiftui padding one line 
Swift :: random element from array swift 
Swift :: remove divider list swiftui 
Swift :: How to control the line spacing in UILabel 
Swift :: swiftui delay 
Swift :: pop the view controller xcode 
Swift :: disable dark mode swift 
Swift :: ios rounded button 
Swift :: swift constraint center vertically 
Swift :: generate random bool swift 
Swift :: swiftui full screen sheet 
Swift :: costume font size swift ui 
Swift :: swift dismiss keyboard on return 
Swift :: set image from asset ios swift 
Swift :: how to set the spacing of a collection view swift 
Swift :: hex color swiftui 
Swift :: how to remove item from list swift 
Swift :: uilabel make bold 
Swift :: swift iterate through string 
Swift :: remove and element from array firebase swift 5 
Swift :: Swift Character Example 
Swift :: sort list ios swift 
Swift :: swift switch statement 
Swift :: how to add dragdown gesture recognizer on view 
Swift :: Swift Weak Reference 
Swift :: dequeueReusableCellWithIdentifier returns nil 
Swift :: swift looping through array 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =