Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
};
051236211B0C00BE00F95AC6 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0810;
TestTargetID = 0512360C1B0C00BE00F95AC6;
};
};
Expand Down Expand Up @@ -435,6 +436,7 @@
INFOPLIST_FILE = Example/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0.1;
};
name = Debug;
};
Expand All @@ -445,6 +447,7 @@
INFOPLIST_FILE = Example/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0.1;
};
name = Release;
};
Expand All @@ -463,6 +466,7 @@
INFOPLIST_FILE = ExampleTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Debug;
Expand All @@ -478,6 +482,7 @@
INFOPLIST_FILE = ExampleTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Release;
Expand Down
8 changes: 4 additions & 4 deletions Example/Example/DetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import MCMHeaderAnimated

class DetailViewController: UIViewController {

var element: NSDictionary! = nil
var color: UIColor! = nil

@IBOutlet weak var header: UIView!


override func viewDidLoad() {
super.viewDidLoad()

header.backgroundColor = self.element.objectForKey("color") as? UIColor
header.backgroundColor = color
}

override func didReceiveMemoryWarning() {
Expand All @@ -35,9 +35,9 @@ extension DetailViewController: MCMHeaderAnimatedDelegate {
return self.header
}

func headerCopy(subview: UIView) -> UIView {
func headerCopy(_ subview: UIView) -> UIView {
let headerN = UIView()
headerN.backgroundColor = self.element.objectForKey("color") as? UIColor
headerN.backgroundColor = color
return headerN
}

Expand Down
2 changes: 1 addition & 1 deletion Example/Example/MainTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MainTableViewCell: UITableViewCell {
super.awakeFromNib()
}

override func setSelected(selected: Bool, animated: Bool) {
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}

Expand Down
50 changes: 22 additions & 28 deletions Example/Example/MainTableViewController.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

//
// MainTableViewController.swift
// Example
Expand All @@ -13,76 +14,69 @@ class MainTableViewController: UITableViewController {

private let transitionManager = MCMHeaderAnimated()

private var elements: NSArray! = []
private var lastSelected: NSIndexPath! = nil
var elements: NSArray! = []
var lastSelected: IndexPath! = nil

override func viewDidLoad() {
super.viewDidLoad()

self.elements = [
["color": UIColor(red: 25/255.0, green: 181/255.0, blue: 254/255.0, alpha: 1.0)],
["color": UIColor(red: 54/255.0, green: 215/255.0, blue: 183/255.0, alpha: 1.0)],
["color": UIColor(red: 210/255.0, green: 77/255.0, blue: 87/255.0, alpha: 1.0)],
["color": UIColor(red: 236/255.0, green: 236/255.0, blue: 236/255.0, alpha: 1.0)]
]

self.elements = [UIColor(red: 25/255.0, green: 181/255.0, blue: 254/255.0, alpha: 1.0), UIColor(red: 54/255.0, green: 215/255.0, blue: 183/255.0, alpha: 1.0), UIColor(red: 210/255.0, green: 77/255.0, blue: 87/255.0, alpha: 1.0), UIColor(red: 236/255.0, green: 236/255.0, blue: 236/255.0, alpha: 1.0)]
}

// MARK: - Table view data source

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.elements.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("mainCell", forIndexPath: indexPath) as! MainTableViewCell

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "mainCell", for: indexPath as IndexPath) as! MainTableViewCell

cell.background.layer.cornerRadius = 10;
cell.background.clipsToBounds = true
cell.header.backgroundColor = self.elements.objectAtIndex(indexPath.row).objectForKey("color") as? UIColor
cell.header.backgroundColor = self.elements.object(at: indexPath.row) as? UIColor

return cell
}

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 180.0
}

// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "viewDetail" {
self.lastSelected = self.tableView.indexPathForSelectedRow
let element = self.elements.objectAtIndex(self.tableView.indexPathForSelectedRow!.row)
self.lastSelected = (self.tableView.indexPathForSelectedRow as NSIndexPath!) as IndexPath!
let element = self.elements.object(at: self.tableView.indexPathForSelectedRow!.row)

let destination = segue.destinationViewController as! DetailViewController
destination.element = element as! NSDictionary
let destination = segue.destination as! DetailViewController
destination.color = element as! UIColor
destination.transitioningDelegate = self.transitionManager

self.transitionManager.destinationViewController = destination
}
}

}

extension MainTableViewController: MCMHeaderAnimatedDelegate {

func headerView() -> UIView {
// Selected cell
let cell = self.tableView.cellForRowAtIndexPath(self.lastSelected) as! MainTableViewCell
let cell = self.tableView.cellForRow(at: self.lastSelected) as! MainTableViewCell
return cell.header
}

func headerCopy(subview: UIView) -> UIView {
let cell = tableView.cellForRowAtIndexPath(self.lastSelected) as! MainTableViewCell
func headerCopy(_ subview: UIView) -> UIView {
let cell = tableView.cellForRow(at: self.lastSelected) as! MainTableViewCell
let header = UIView(frame: cell.header.frame)
header.backgroundColor = self.elements.objectAtIndex(self.lastSelected.row).objectForKey("color") as? UIColor
header.backgroundColor = self.elements.object(at: self.lastSelected.row) as? UIColor

return header
}

}
2 changes: 1 addition & 1 deletion Example/ExampleTests/ExampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ExampleTests: XCTestCase {

func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
self.measure() {
// Put the code you want to measure the time of here.
}
}
Expand Down
6 changes: 6 additions & 0 deletions MCMHeaderAnimated/MCMHeaderAnimated.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@
TargetAttributes = {
0512363B1B0C00FD00F95AC6 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0810;
};
051236461B0C00FD00F95AC6 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0810;
};
};
};
Expand Down Expand Up @@ -348,6 +350,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -364,6 +367,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -381,6 +385,7 @@
INFOPLIST_FILE = MCMHeaderAnimatedTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -394,6 +399,7 @@
INFOPLIST_FILE = MCMHeaderAnimatedTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MCMHeaderAnimatedTests: XCTestCase {

func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
self.measure() {
// Put the code you want to measure the time of here.
}
}
Expand Down
Loading