Latest 1.0.0
Homepage https://github.com/soheil/SwiftCSS
License MIT
Platforms ios 8.0, requires ARC
Authors

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.

Latest podspec

{
    "name": "SwiftCSS",
    "version": "1.0.0",
    "summary": "SwiftCSS extends UIView by providing CSS-like properties to position and size elements.",
    "description": "Quickly style and size any element in your iOS app. Simply add elements like lables and buttons to your view and then use CSS-like attributes like .marginTop=50, width=30% to style them.",
    "homepage": "https://github.com/soheil/SwiftCSS",
    "license": "MIT",
    "authors": {
        "Soheil": "[email protected]"
    },
    "source": {
        "git": "https://github.com/soheil/SwiftCSS.git",
        "tag": "1.0.0"
    },
    "social_media_url": "https://twitter.com/soheil",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "SwiftCSS": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This