Commit b5ac48a4 by Daniel Dahan

added defaults for MaterialTextLayer

parent 815e678f
......@@ -19,7 +19,6 @@
import UIKit
public class MaterialLayer : CAShapeLayer {
/**
:name: init
*/
......
......@@ -19,7 +19,10 @@
import UIKit
public extension UIFont {
func sizeOfString(string: String, constrainedToWidth width: Double) -> CGSize {
/**
:name: sizeOfString
*/
public func sizeOfString(string: String, constrainedToWidth width: Double) -> CGSize {
return string.boundingRectWithSize(CGSize(width: width, height: DBL_MAX),
options: NSStringDrawingOptions.UsesLineFragmentOrigin,
attributes: [NSFontAttributeName: self],
......@@ -28,17 +31,14 @@ public extension UIFont {
}
public class MaterialTextLayer : CATextLayer {
/**
:name: text
*/
public var text: String? {
didSet {
string = text as? AnyObject
}
}
//
// :name: internalFont
//
private var internalFont: UIFont?
/**
:name: font
*/
public override var font: AnyObject? {
get {
return internalFont
......@@ -53,25 +53,22 @@ public class MaterialTextLayer : CATextLayer {
}
/**
:name: pointSize
:name: text
*/
public var pointSize: CGFloat = 10 {
public var text: String? {
didSet {
fontSize = pointSize
string = text as? AnyObject
}
}
/**
:name: font
:name: pointSize
*/
// public override var font: AnyObject? {
//// didSet {
//// if let v = font as? UIFont {
//// super.font = CGFontCreateWithFontName(v.fontName as CFStringRef)!
//// pointSize = v.pointSize
//// }
//// }
// }
public var pointSize: CGFloat = 10 {
didSet {
fontSize = pointSize
}
}
/**
:name: textColor
......@@ -169,11 +166,12 @@ public class MaterialTextLayer : CATextLayer {
// :name: prepareLayer
//
internal func prepareLayer() {
textColor = MaterialColor.black
textAlignment = MaterialTheme.label.textAlignment
wrapped = MaterialTheme.label.wrapped
contentsScale = MaterialTheme.label.contentsScale
font = MaterialTheme.label.font
textColor = MaterialTheme.textLayer.textColor
textAlignment = MaterialTheme.textLayer.textAlignment
wrapped = MaterialTheme.textLayer.wrapped
contentsScale = MaterialTheme.textLayer.contentsScale
font = MaterialTheme.textLayer.font
lineBreakMode = MaterialTheme.textLayer.lineBreakMode
}
}
......@@ -24,6 +24,7 @@ public struct MaterialTheme {
public struct basicCardView {}
public struct imageCardView {}
public struct navigationBarView {}
public struct textLayer {}
public struct label {}
public struct flatButton {}
public struct raisedButton {}
......@@ -216,6 +217,23 @@ public extension MaterialTheme.navigationBarView {
public static var zPosition: CGFloat = 100
}
// textLayer
public extension MaterialTheme.textLayer {
// scale
public static var contentsScale: CGFloat = UIScreen.mainScreen().scale
// alignment
public static var wrapped: Bool = true
public static var textAlignment: NSTextAlignment = .Left
public static var lineBreakMode: NSLineBreakMode = .ByWordWrapping
// font
public static var font: UIFont = RobotoFont.regular
// color
public static var textColor: UIColor = MaterialColor.black
}
// label
public extension MaterialTheme.label {
// scale
......@@ -226,7 +244,7 @@ public extension MaterialTheme.label {
public static var textAlignment: NSTextAlignment = .Left
// font
public static var font: UIFont = RobotoFont.regularWithSize(20)
public static var font: UIFont = RobotoFont.regular
}
// flatButton
......
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