Skip to content

Commit

Permalink
#3 working on label
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Jun 4, 2016
1 parent 8b5f541 commit 7ad3320
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions Sources/Cacao/Label.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public final class Label: Drawable, Appearance {

public var color: Color = Label.appearance.color

public var textAlignment: TextAlignment = .left

// MARK: - Initialization

public init(frame: Rect = Rect(), text: String = "") {
Expand All @@ -43,13 +45,16 @@ public final class Label: Drawable, Appearance {
let bounds = Rect(size: frame.size)

var attributes = TextAttributes()

attributes.font = font

attributes.color = color
attributes.paragraphStyle.alignment = textAlignment

text.draw(in: bounds, context: context, attributes: attributes)
}

// MARK: - Size


}

// MARK: - Appearance
Expand Down
8 changes: 4 additions & 4 deletions Sources/Demo/ContentModeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ final class ContentModeViewController: ViewController {

lazy var label: Label = Label(frame: Rect(), text: "\(self.modes[0])")

lazy var labelContainer: ContentView = ContentView(content: self.label, mode: .center)

lazy var logoView: SwiftLogoView = SwiftLogoView()

lazy var button: Button = Button(content: self.logoView, mode: self.modes[0])
Expand All @@ -39,9 +37,11 @@ final class ContentModeViewController: ViewController {

button.action = changeMode

label.textAlignment = .center

backgroundView.addSubview(button)

backgroundView.addSubview(labelContainer)
backgroundView.addSubview(label)

return backgroundView
}
Expand All @@ -52,7 +52,7 @@ final class ContentModeViewController: ViewController {

// from Paint Code

labelContainer.frame = Rect(x: frame.minX + floor(frame.width * 0.00000 + 0.5), y: frame.minY + floor(frame.height * 0.82812 + 0.5), width: floor(frame.width * 1.00000 + 0.5) - floor(frame.width * 0.00000 + 0.5), height: floor(frame.height * 1.00000 + 0.5) - floor(frame.height * 0.82812 + 0.5))
label.frame = Rect(x: frame.minX + floor(frame.width * 0.00000 + 0.5), y: frame.minY + floor(frame.height * 0.82812 + 0.5), width: floor(frame.width * 1.00000 + 0.5) - floor(frame.width * 0.00000 + 0.5), height: floor(frame.height * 1.00000 + 0.5) - floor(frame.height * 0.82812 + 0.5))

button.frame = Rect(x: frame.minX + floor(frame.width * 0.00000 + 0.5), y: frame.minY + floor(frame.height * 0.00000 + 0.5), width: floor(frame.width * 1.00000 + 0.5) - floor(frame.width * 0.00000 + 0.5), height: floor(frame.height * 0.82812 + 0.5) - floor(frame.height * 0.00000 + 0.5))
}
Expand Down

0 comments on commit 7ad3320

Please sign in to comment.