Skip to content

SwiftCSS extends UIView by providing CSS-like properties to position and size elements.

License

Notifications You must be signed in to change notification settings

soheil-zz/SwiftCSS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftCSS

SwiftCSS extends UIView by providing CSS-like properties to position and size elements.

        let name = UILabel()
        name.text = "Look at me I'm some text"
        name.textAlignment = NSTextAlignment.Center
        name.marginTop = 20 // 20 pixels below the top of the page
        name.widthPercent = 80 // centers with a width of 80% of the page

        let addBtn = UIButton()
        name.marginTop = 20 // 20 pixels below the previous element
        addBtn.widthPercent = 100
        addBtn.height = 50 //pixels
        addBtn.marginBottomAbsolute = 0 //snaps to the bottom of the page

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Note The order in which views are added to a parent view is important, just like in HTML.

Available Properties

marginTop
marginTopAbsolute
marginBottom
marginBottomAbsolute
marginLeft
widthPercent
heightPercent
width
height

Example Screenshot

screenshot

Installation

SwiftCSS is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SwiftCSS"

Author

@soheil

License

SwiftCSS is available under the MIT license. See the LICENSE file for more info.

About

SwiftCSS extends UIView by providing CSS-like properties to position and size elements.

Resources

License

Stars

Watchers

Forks

Packages

No packages published