Skip to content

Commit

Permalink
Merge pull request #45 from mamaral/swift-3
Browse files Browse the repository at this point in the history
Swift 3
  • Loading branch information
mamaral committed Aug 25, 2016
2 parents 8097674 + 492aae3 commit 0bc4d6e
Show file tree
Hide file tree
Showing 17 changed files with 773 additions and 773 deletions.
12 changes: 6 additions & 6 deletions Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow.init(frame: UIScreen.mainScreen().bounds)
self.window?.backgroundColor = UIColor.whiteColor()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow.init(frame: UIScreen.main().bounds)
self.window?.backgroundColor = UIColor.white()

// The facebook example from the README.... Don't ask why the file name is FacebookProfileExampleViewController
// but the class referenced here is TwitterProfileExampleViewController... I didn't realize you can't yet refactor
// swift code, and somehow this still works...
UINavigationBar.appearance().barTintColor = UIColor(red: 80/255.0, green: 108/255.0, blue: 163/255.0, alpha: 1.0)
UINavigationBar.appearance().translucent = false
UINavigationBar.appearance().isTranslucent = false
// self.window?.rootViewController = UINavigationController(rootViewController: TwitterProfileExampleViewController())

// Used for tinkering and testing new methods - uncomment this out if you want to experiment!
self.window?.rootViewController = TestViewController()
// self.window?.rootViewController = TestViewController()

// This is crazy-complex demo I have on the README. Uncomment this out to experience with that as well,
// although I really built it for iPads.
// self.window?.rootViewController = ViewController()
self.window?.rootViewController = ViewController()

self.window?.makeKeyAndVisible()
return true
Expand Down
22 changes: 11 additions & 11 deletions Demo/FacebookProfileExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TwitterProfileExampleViewController: UIViewController {
let bannerMaskView : UIView = UIView()
let avatarImageView : UIImageView = UIImageView()
let nameLabel : UILabel = UILabel()
let cameraButton : UIButton = UIButton(type: .Custom)
let cameraButton : UIButton = UIButton(type: .custom)

let buttonContainerView : UIView = UIView()
let postButton : IconButton = IconButton()
Expand All @@ -35,30 +35,30 @@ class TwitterProfileExampleViewController: UIViewController {
// So I cheated here... shhhh!
// (can't take all damn day making this match perfectly!)
searchBar.image = UIImage(named: "searchBar")
searchBar.contentMode = .ScaleAspectFit
searchBar.contentMode = .scaleAspectFit

bannerImageView.image = UIImage(named: "banner")
bannerImageView.contentMode = .ScaleAspectFill
bannerImageView.contentMode = .scaleAspectFill
bannerImageView.clipsToBounds = true

bannerMaskView.backgroundColor = UIColor(white: 0.0, alpha: 0.2)

avatarImageView.image = UIImage(named: "avatar")
avatarImageView.layer.cornerRadius = 1.0
avatarImageView.layer.borderColor = UIColor.whiteColor().CGColor
avatarImageView.layer.borderColor = UIColor.white().cgColor
avatarImageView.layer.borderWidth = 2.0
avatarImageView.clipsToBounds = true

cameraButton.setImage(UIImage(named: "camera"), forState: .Normal)
cameraButton.setImage(UIImage(named: "camera"), for: .normal)

nameLabel.textColor = UIColor.whiteColor()
nameLabel.textColor = UIColor.white()
nameLabel.text = "Mike\nAmaral"
nameLabel.numberOfLines = 2
nameLabel.font = UIFont(name: "HelveticaNeue-Light", size: 33)

buttonContainerView.backgroundColor = UIColor.whiteColor()
buttonContainerView.layer.shadowColor = UIColor.blackColor().CGColor
buttonContainerView.layer.shadowOffset = CGSizeMake(0, 0.5)
buttonContainerView.backgroundColor = UIColor.white()
buttonContainerView.layer.shadowColor = UIColor.black().cgColor
buttonContainerView.layer.shadowOffset = CGSize(width: 0, height: 0.5)
buttonContainerView.layer.shadowOpacity = 0.4

postButton.label.text = "Post"
Expand All @@ -73,7 +73,7 @@ class TwitterProfileExampleViewController: UIViewController {
moreButton.label.text = "More"
moreButton.imageView.image = UIImage(named: "more")

buttonContainerView2.backgroundColor = UIColor.clearColor()
buttonContainerView2.backgroundColor = UIColor.clear()

aboutView.imageView.image = UIImage(named: "about")
aboutView.label.text = "About"
Expand Down Expand Up @@ -117,7 +117,7 @@ class TwitterProfileExampleViewController: UIViewController {
}

func layoutFrames() {
let isLandscape : Bool = UIDevice.currentDevice().orientation.isLandscape.boolValue
let isLandscape : Bool = UIDevice.current().orientation.isLandscape.boolValue
let bannerHeight : CGFloat = view.height * 0.465
let avatarHeightMultipler : CGFloat = isLandscape ? 0.75 : 0.43
let avatarSize = bannerHeight * avatarHeightMultipler
Expand Down
10 changes: 5 additions & 5 deletions Demo/IconButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ class IconButton: UIView {
let label : UILabel = UILabel()

convenience init() {
self.init(frame: CGRectZero)
self.init(frame: CGRect.zero)

imageView.contentMode = .ScaleAspectFill
imageView.contentMode = .scaleAspectFill
self.addSubview(imageView)

label.textAlignment = .Center
label.textAlignment = .center
label.textColor = UIColor(red: 106/255.0, green: 113/255.0, blue: 127/255.0, alpha: 1.0)
label.font = UIFont.systemFontOfSize(13.0)
label.font = UIFont.systemFont(ofSize: 13.0)
self.addSubview(label)
}

override func layoutSubviews() {
super.layoutSubviews()

imageView.anchorToEdge(.Top, padding: 0, width: 24, height: 24)
label.align(.UnderCentered, relativeTo: imageView, padding: 5, width: self.width, height: 15)
label.align(align: .UnderCentered, relativeTo: imageView, padding: 5, width: self.width, height: 15)
}
}
14 changes: 7 additions & 7 deletions Demo/ImageContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ class ImageContainerView: UIView {
let label : UILabel = UILabel()

convenience init() {
self.init(frame: CGRectZero)
self.init(frame: CGRect.zero)

self.backgroundColor = UIColor.whiteColor()
self.backgroundColor = UIColor.white()
self.layer.cornerRadius = 4.0
self.layer.borderWidth = 1.0
self.layer.borderColor = UIColor(white: 0.68, alpha: 1.0).CGColor
self.layer.borderColor = UIColor(white: 0.68, alpha: 1.0).cgColor
self.clipsToBounds = true

imageView.contentMode = .ScaleAspectFill
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
self.addSubview(imageView)

label.textAlignment = .Center
label.textColor = UIColor.blackColor()
label.font = UIFont.boldSystemFontOfSize(14.0)
label.textAlignment = .center
label.textColor = UIColor.black()
label.font = UIFont.boldSystemFont(ofSize: 14.0)
self.addSubview(label)
}

Expand Down
72 changes: 36 additions & 36 deletions Demo/TestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,84 +26,84 @@ class TestViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

anchorLayer.backgroundColor = UIColor.redColor().CGColor
anchorLayer.backgroundColor = UIColor.red().cgColor
view.layer.addSublayer(anchorLayer)

anchorViewA.backgroundColor = UIColor(red: 229/255.0, green: 72/255.0, blue: 26/255.0, alpha: 1.0)
anchorViewA.text = ""
anchorViewA.textAlignment = .Center
anchorViewA.font = UIFont.boldSystemFontOfSize(20)
anchorViewA.textColor = UIColor.whiteColor()
anchorViewA.textAlignment = .center
anchorViewA.font = UIFont.boldSystemFont(ofSize: 20)
anchorViewA.textColor = UIColor.white()
view.addSubview(anchorViewA)

anchorViewB.backgroundColor = UIColor(red: 229/255.0, green: 72/255.0, blue: 26/255.0, alpha: 1.0)
anchorViewB.text = ""
anchorViewB.textAlignment = .Center
anchorViewB.font = UIFont.boldSystemFontOfSize(20)
anchorViewB.textColor = UIColor.whiteColor()
anchorViewB.textAlignment = .center
anchorViewB.font = UIFont.boldSystemFont(ofSize: 20)
anchorViewB.textColor = UIColor.white()
view.addSubview(anchorViewB)

anchorViewC.backgroundColor = UIColor(red: 229/255.0, green: 72/255.0, blue: 26/255.0, alpha: 1.0)
anchorViewC.text = "C"
anchorViewC.textAlignment = .Center
anchorViewC.font = UIFont.boldSystemFontOfSize(20)
anchorViewC.textColor = UIColor.whiteColor()
anchorViewC.textAlignment = .center
anchorViewC.font = UIFont.boldSystemFont(ofSize: 20)
anchorViewC.textColor = UIColor.white()
view.addSubview(anchorViewC)

anchorViewD.backgroundColor = UIColor(red: 229/255.0, green: 72/255.0, blue: 26/255.0, alpha: 1.0)
anchorViewD.text = "D"
anchorViewD.textAlignment = .Center
anchorViewD.font = UIFont.boldSystemFontOfSize(20)
anchorViewD.textColor = UIColor.whiteColor()
anchorViewD.textAlignment = .center
anchorViewD.font = UIFont.boldSystemFont(ofSize: 20)
anchorViewD.textColor = UIColor.white()
view.addSubview(anchorViewD)

view1.backgroundColor = UIColor(red: 78/255.0, green: 102/255.0, blue: 131/255.0, alpha: 1.0)
view1.text = "1"
view1.textAlignment = .Center
view1.font = UIFont.boldSystemFontOfSize(20)
view1.textColor = UIColor.whiteColor()
view1.textAlignment = .center
view1.font = UIFont.boldSystemFont(ofSize: 20)
view1.textColor = UIColor.white()
view.addSubview(view1)

view2.backgroundColor = UIColor(red: 132/255.0, green: 169/255.0, blue: 57/255.0, alpha: 1.0)
view2.text = "2"
view2.textAlignment = .Center
view2.font = UIFont.boldSystemFontOfSize(20)
view2.textColor = UIColor.whiteColor()
view2.textAlignment = .center
view2.font = UIFont.boldSystemFont(ofSize: 20)
view2.textColor = UIColor.white()
view.addSubview(view2)

view3.backgroundColor = UIColor(red: 78/255.0, green: 102/255.0, blue: 131/255.0, alpha: 1.0)
view3.text = "3"
view3.textAlignment = .Center
view3.font = UIFont.boldSystemFontOfSize(20)
view3.textColor = UIColor.whiteColor()
view3.textAlignment = .center
view3.font = UIFont.boldSystemFont(ofSize: 20)
view3.textColor = UIColor.white()
view.addSubview(view3)

view4.backgroundColor = UIColor(red: 132/255.0, green: 169/255.0, blue: 57/255.0, alpha: 1.0)
view4.text = "4"
view4.textAlignment = .Center
view4.font = UIFont.boldSystemFontOfSize(20)
view4.textColor = UIColor.whiteColor()
view4.textAlignment = .center
view4.font = UIFont.boldSystemFont(ofSize: 20)
view4.textColor = UIColor.white()
view.addSubview(view4)

view5.backgroundColor = UIColor(red: 78/255.0, green: 102/255.0, blue: 131/255.0, alpha: 1.0)
view5.text = "5"
view5.textAlignment = .Center
view5.font = UIFont.boldSystemFontOfSize(20)
view5.textColor = UIColor.whiteColor()
view5.textAlignment = .center
view5.font = UIFont.boldSystemFont(ofSize: 20)
view5.textColor = UIColor.white()
view.addSubview(view5)

view6.backgroundColor = UIColor(red: 132/255.0, green: 169/255.0, blue: 57/255.0, alpha: 1.0)
view6.text = "6"
view6.textAlignment = .Center
view6.font = UIFont.boldSystemFontOfSize(20)
view6.textColor = UIColor.whiteColor()
view6.textAlignment = .center
view6.font = UIFont.boldSystemFont(ofSize: 20)
view6.textColor = UIColor.white()
view.addSubview(view6)

testLabel.backgroundColor = UIColor(red: 132/255.0, green: 169/255.0, blue: 57/255.0, alpha: 1.0)
testLabel.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
testLabel.textAlignment = .Center
testLabel.font = UIFont.boldSystemFontOfSize(14)
testLabel.textColor = UIColor.whiteColor()
testLabel.textAlignment = .center
testLabel.font = UIFont.boldSystemFont(ofSize: 14)
testLabel.textColor = UIColor.white()
testLabel.numberOfLines = 0
view.addSubview(testLabel)
}
Expand All @@ -112,7 +112,7 @@ class TestViewController: UIViewController {
super.viewWillLayoutSubviews()

anchorViewA.anchorInCorner(.TopLeft, xPad: 20, yPad: 20, width: 200, height: 200)
view1.align(.ToTheRightMatchingTop, relativeTo: anchorViewA, padding: 20, width: 100, height: 100, offset: 20)
view2.align(.UnderMatchingLeft, relativeTo: anchorViewA, padding: 20, width: 100, height: 100, offset: 20)
view1.align(align: .ToTheRightMatchingTop, relativeTo: anchorViewA, padding: 20, width: 100, height: 100, offset: 20)
view2.align(align: .UnderMatchingLeft, relativeTo: anchorViewA, padding: 20, width: 100, height: 100, offset: 20)
}
}
Loading

0 comments on commit 0bc4d6e

Please sign in to comment.