Last active
August 29, 2015 14:21
-
-
Save mcmurrym/a365603bdee65c6adf61 to your computer and use it in GitHub Desktop.
Add Layout margin controls to IB. I hope Apple eventually integrates a layoutMargin attribute control into IB, until then this should do the trick. Just drop it in to your project and it should show up in IB. For iOS 8.0 and up
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
// UIViewIBLayoutMarginSupport.swift | |
// Created by Matt McMurry on 5/26/15. | |
import UIKit | |
public extension UIView { | |
@IBInspectable public var leftLayoutMagrin: CGFloat { | |
set { | |
var margins = layoutMargins | |
margins.left = newValue | |
layoutMargins = margins | |
} | |
get { | |
return layoutMargins.left | |
} | |
} | |
@IBInspectable public var rightLayoutMagrin: CGFloat { | |
set { | |
var margins = layoutMargins | |
margins.right = newValue | |
layoutMargins = margins | |
} | |
get { | |
return layoutMargins.right | |
} | |
} | |
@IBInspectable public var topLayoutMagrin: CGFloat { | |
set { | |
var margins = layoutMargins | |
margins.top = newValue | |
layoutMargins = margins | |
} | |
get { | |
return layoutMargins.top | |
} | |
} | |
@IBInspectable public var bottomLayoutMagrin: CGFloat { | |
set { | |
var margins = layoutMargins | |
margins.bottom = newValue | |
layoutMargins = margins | |
} | |
get { | |
return layoutMargins.bottom | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment