Commit 84168221 by Daniel Dahan

updated Storyboards detection

parent f9468e49
......@@ -42,6 +42,32 @@ class ViewController: UIViewController {
view.addSubview(tabBar)
let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.white
btn1.pulseScale = false
btn1.setTitle("ONE", forState: .Normal)
btn1.setTitleColor(MaterialColor.white, forState: .Normal)
let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.white
btn2.pulseScale = false
btn2.setTitle("TWO", forState: .Normal)
btn2.setTitleColor(MaterialColor.white, forState: .Normal)
let btn3: FlatButton = FlatButton()
btn3.pulseColor = MaterialColor.white
btn3.pulseScale = false
btn3.setTitle("THREE", forState: .Normal)
btn3.setTitleColor(MaterialColor.white, forState: .Normal)
let btn4: FlatButton = FlatButton()
btn4.pulseColor = MaterialColor.white
btn4.pulseScale = false
btn4.setTitle("FOUR", forState: .Normal)
btn4.setTitleColor(MaterialColor.white, forState: .Normal)
tabBar.buttons = [btn1, btn2, btn3, btn4]
}
/// Prepares view.
......
......@@ -365,6 +365,9 @@ Add a new dimension of interactivity with CaptureView. CaptureView is a fully fu
* TabBarController
* Scrolling Techniques
* Snackbar
* Bottom Sheets
* Dialogs
* Collapsing Toolbar
* Advanced Camera / Audio Toolset & Views
* More Examples
......
......@@ -66,7 +66,7 @@ public class CardView : MaterialPulseView {
/**
:name: dividerInset
*/
public var dividerInset: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0) {
@IBInspectable public var dividerInset: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0) {
didSet {
reloadView()
}
......@@ -84,7 +84,7 @@ public class CardView : MaterialPulseView {
/**
:name: contentInset
*/
public var contentInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
@IBInspectable public var contentInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
didSet {
reloadView()
}
......@@ -102,7 +102,7 @@ public class CardView : MaterialPulseView {
/**
:name: titleLabelInset
*/
public var titleLabelInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
@IBInspectable public var titleLabelInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
didSet {
reloadView()
}
......@@ -111,7 +111,7 @@ public class CardView : MaterialPulseView {
/**
:name: titleLabel
*/
public var titleLabel: UILabel? {
@IBInspectable public var titleLabel: UILabel? {
didSet {
titleLabel?.translatesAutoresizingMaskIntoConstraints = false
reloadView()
......@@ -130,7 +130,7 @@ public class CardView : MaterialPulseView {
/**
:name: detailViewInset
*/
public var detailViewInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
@IBInspectable public var detailViewInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
didSet {
reloadView()
}
......@@ -139,7 +139,7 @@ public class CardView : MaterialPulseView {
/**
:name: detailView
*/
public var detailView: UIView? {
@IBInspectable public var detailView: UIView? {
didSet {
detailView?.translatesAutoresizingMaskIntoConstraints = false
reloadView()
......@@ -158,7 +158,7 @@ public class CardView : MaterialPulseView {
/**
:name: leftButtonsInset
*/
public var leftButtonsInset: UIEdgeInsets = MaterialEdgeInsetToValue(.None) {
@IBInspectable public var leftButtonsInset: UIEdgeInsets = MaterialEdgeInsetToValue(.None) {
didSet {
reloadView()
}
......@@ -190,7 +190,7 @@ public class CardView : MaterialPulseView {
/**
:name: rightButtonsInset
*/
public var rightButtonsInset: UIEdgeInsets = MaterialEdgeInsetToValue(.None) {
@IBInspectable public var rightButtonsInset: UIEdgeInsets = MaterialEdgeInsetToValue(.None) {
didSet {
reloadView()
}
......
......@@ -47,7 +47,7 @@ public class ControlView : MaterialView {
}
/// A wrapper around grid.contentInset.
public var contentInset: UIEdgeInsets {
@IBInspectable public var contentInset: UIEdgeInsets {
get {
return grid.contentInset
}
......@@ -77,7 +77,7 @@ public class ControlView : MaterialView {
public private(set) lazy var contentView: MaterialView = MaterialView()
/// Left side UIControls.
@IBInspectable public var leftControls: Array<UIControl>? {
public var leftControls: Array<UIControl>? {
didSet {
if let v: Array<UIControl> = oldValue {
for b in v {
......@@ -95,7 +95,7 @@ public class ControlView : MaterialView {
}
/// Right side UIControls.
@IBInspectable public var rightControls: Array<UIControl>? {
public var rightControls: Array<UIControl>? {
didSet {
if let v: Array<UIControl> = oldValue {
for b in v {
......
......@@ -66,7 +66,7 @@ public class ImageCardView : MaterialPulseView {
/**
:name: dividerInset
*/
public var dividerInset: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0) {
@IBInspectable public var dividerInset: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0) {
didSet {
reloadView()
}
......@@ -177,7 +177,7 @@ public class ImageCardView : MaterialPulseView {
/**
:name: contentInset
*/
public var contentInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
@IBInspectable public var contentInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
didSet {
reloadView()
}
......@@ -195,7 +195,7 @@ public class ImageCardView : MaterialPulseView {
/**
:name: titleLabelInset
*/
public var titleLabelInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
@IBInspectable public var titleLabelInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
didSet {
reloadView()
}
......@@ -204,7 +204,7 @@ public class ImageCardView : MaterialPulseView {
/**
:name: titleLabel
*/
public var titleLabel: UILabel? {
@IBInspectable public var titleLabel: UILabel? {
didSet {
titleLabel?.translatesAutoresizingMaskIntoConstraints = false
reloadView()
......@@ -223,7 +223,7 @@ public class ImageCardView : MaterialPulseView {
/**
:name: detailViewInset
*/
public var detailViewInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
@IBInspectable public var detailViewInset: UIEdgeInsets = MaterialEdgeInsetToValue(.Square2) {
didSet {
reloadView()
}
......@@ -232,7 +232,7 @@ public class ImageCardView : MaterialPulseView {
/**
:name: detailView
*/
public var detailView: UIView? {
@IBInspectable public var detailView: UIView? {
didSet {
detailView?.translatesAutoresizingMaskIntoConstraints = false
reloadView()
......@@ -251,7 +251,7 @@ public class ImageCardView : MaterialPulseView {
/**
:name: leftButtonsInset
*/
public var leftButtonsInset: UIEdgeInsets = MaterialEdgeInsetToValue(.None) {
@IBInspectable public var leftButtonsInset: UIEdgeInsets = MaterialEdgeInsetToValue(.None) {
didSet {
reloadView()
}
......@@ -283,7 +283,7 @@ public class ImageCardView : MaterialPulseView {
/**
:name: rightButtonsInset
*/
public var rightButtonsInset: UIEdgeInsets = MaterialEdgeInsetToValue(.None) {
@IBInspectable public var rightButtonsInset: UIEdgeInsets = MaterialEdgeInsetToValue(.None) {
didSet {
reloadView()
}
......
......@@ -142,7 +142,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
}
/// A wrapper around grid.contentInset.
public var contentInset: UIEdgeInsets {
@IBInspectable public var contentInset: UIEdgeInsets {
get {
return contentView.grid.contentInset
}
......
......@@ -30,22 +30,90 @@
import UIKit
public enum TabBarLineAlignment {
case Top
case Bottom
}
public class TabBar : MaterialView {
/// A reference to the line UIView.
public private(set) var line: UIView!
/// A value for the line alignment.
public var lineAlignment: TabBarLineAlignment = .Bottom {
didSet {
layoutSubviews()
}
}
/// Will render the view.
public var willRenderView: Bool {
return 0 < width
}
/// Buttons.
// public var buttons: Array<UIButton>? {
// didSet {
// if let v: Array<UIButton> = oldValue {
// for b in v {
// b.removeFromSuperview()
// }
// }
//
// if let v: Array<UIControl> = leftControls {
// for b in v {
// addSubview(b)
// }
// }
// layoutSubviews()
// }
// }
public var buttons: Array<UIButton>? {
didSet {
if let v: Array<UIButton> = oldValue {
for b in v {
b.removeFromSuperview()
}
}
if let v: Array<UIButton> = buttons {
for b in v {
addSubview(b)
}
}
layoutSubviews()
}
}
public override func layoutSubviews() {
super.layoutSubviews()
if willRenderView {
if let v: Array<UIButton> = buttons {
if 0 < v.count {
let columns: Int = grid.axis.columns / v.count
for b in v {
b.grid.columns = columns
b.contentEdgeInsets = UIEdgeInsetsZero
b.layer.cornerRadius = 0
b.removeTarget(self, action: #selector(handleButton(_:)), forControlEvents: .TouchUpInside)
b.addTarget(self, action: #selector(handleButton(_:)), forControlEvents: .TouchUpInside)
}
grid.views = v as Array<UIView>
line.frame = CGRectMake(0, .Bottom == lineAlignment ? height - 3 : 0, v.first!.frame.width, 3)
}
}
}
}
/// Handles the button touch event.
internal func handleButton(button: UIButton) {
UIView.animateWithDuration(0.25, animations: { [unowned self] in
self.line.frame.origin.x = button.frame.origin.x
self.line.frame.size.width = button.frame.size.width
})
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public override func prepareView() {
super.prepareView()
autoresizingMask = .FlexibleWidth
prepareBottomLayer()
}
// Prepares the bottomLayer.
private func prepareBottomLayer() {
line = UIView()
line.backgroundColor = MaterialColor.yellow.base
addSubview(line)
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment