Commit 55d463fa by Daniel Dahan

experimental: added truncation to MaterialLabel and updated defaults for NavigationBarView

parent 270558a5
......@@ -58,12 +58,21 @@ public class MaterialLabel : UILabel {
didSet {
if let v = font {
textLayer.font = CGFontCreateWithFontName(v.fontName as CFStringRef)!
textLayer.fontSize = v.pointSize
pointSize = v.pointSize
}
}
}
/**
:name: pointSize
*/
public var pointSize: CGFloat! {
didSet {
textLayer.fontSize = pointSize
}
}
/**
:name: textAlignment
*/
public override var textAlignment: NSTextAlignment {
......@@ -102,6 +111,34 @@ public class MaterialLabel : UILabel {
}
/**
:name: lineBreakMode
*/
public override var lineBreakMode: NSLineBreakMode {
didSet {
switch lineBreakMode {
case .ByWordWrapping: // Wrap at word boundaries, default
wrapped = true
textLayer.truncationMode = kCATruncationNone
case .ByCharWrapping: // Wrap at character boundaries
wrapped = true
textLayer.truncationMode = kCATruncationNone
case .ByClipping: // Simply clip
wrapped = false
textLayer.truncationMode = kCATruncationNone
case .ByTruncatingHead: // Truncate at head of line: "...wxyz"
wrapped = false
textLayer.truncationMode = kCATruncationStart
case .ByTruncatingTail: // Truncate at tail of line: "abcd..."
wrapped = false
textLayer.truncationMode = kCATruncationEnd
case .ByTruncatingMiddle: // Truncate middle of line: "ab...yz"
wrapped = false
textLayer.truncationMode = kCATruncationMiddle
}
}
}
/**
:name: init
*/
public required init?(coder aDecoder: NSCoder) {
......@@ -130,5 +167,6 @@ public class MaterialLabel : UILabel {
textAlignment = MaterialTheme.label.textAlignment
wrapped = MaterialTheme.label.wrapped
contentsScale = MaterialTheme.label.contentsScale
font = MaterialTheme.label.font
}
}
\ No newline at end of file
......@@ -119,7 +119,7 @@ public extension MaterialTheme.navigation {
// shape
public static var masksToBounds: Bool = MaterialTheme.view.masksToBounds
public static var cornerRadius: MaterialRadius = MaterialTheme.view.cornerRadius
public static var titleInsetsRef: MaterialInsetsType = (top: 0, left: 8, bottom: 12, right: 8)
public static var titleInsetsRef: MaterialInsetsType = (top: 0, left: 8, bottom: 10, right: 8)
public static var leftButtonsInsetsRef: MaterialInsetsType = (top: 0, left: 8, bottom: 8, right: 0)
public static var rightButtonsInsetsRef: MaterialInsetsType = (top: 0, left: 0, bottom: 8, right: 8)
......@@ -149,9 +149,12 @@ public extension MaterialTheme.label {
// scale
public static var contentsScale: CGFloat = UIScreen.mainScreen().scale
// text
// alignment
public static var wrapped: Bool = true
public static var textAlignment: NSTextAlignment = .Left
// font
public static var font: UIFont = RobotoFont.regularWithSize(20)
}
// button.flat
......
......@@ -164,6 +164,7 @@ public class NavigationBarView: MaterialView {
v.removeFromSuperview()
}
// leftButtons
if let v = leftButtons {
var h: String = "H:|"
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
......
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