Commit 36c254b6 by Daniel Dahan

updated README with CardView example 2

parent adb40f58
......@@ -13,6 +13,7 @@
967513D41C136BB7009F455A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 967513D21C136BB7009F455A /* LaunchScreen.storyboard */; };
967513DC1C136BE3009F455A /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 967513DB1C136BE3009F455A /* MaterialKit.framework */; };
967513DD1C136BE3009F455A /* MaterialKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 967513DB1C136BE3009F455A /* MaterialKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
967513E01C13A98E009F455A /* ContentKit+UIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513DF1C13A98E009F455A /* ContentKit+UIImage.swift */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -37,6 +38,7 @@
967513D31C136BB7009F455A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
967513D51C136BB7009F455A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
967513DB1C136BE3009F455A /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = MaterialKit.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/MaterialKit-anypxbsecgdqqxevbavirvnffqxd/Build/Products/Debug-iphoneos/MaterialKit.framework"; sourceTree = "<absolute>"; };
967513DF1C13A98E009F455A /* ContentKit+UIImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ContentKit+UIImage.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -76,6 +78,7 @@
967513D01C136BB7009F455A /* Assets.xcassets */,
967513D21C136BB7009F455A /* LaunchScreen.storyboard */,
967513D51C136BB7009F455A /* Info.plist */,
967513DF1C13A98E009F455A /* ContentKit+UIImage.swift */,
);
path = CardView;
sourceTree = "<group>";
......@@ -151,6 +154,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
967513E01C13A98E009F455A /* ContentKit+UIImage.swift in Sources */,
967513CC1C136BB7009F455A /* ViewController.swift in Sources */,
967513CA1C136BB7009F455A /* AppDelegate.swift in Sources */,
);
......
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io> and other CosmicMind contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import UIKit
// Code extracted from ContentKit for example usage.
public extension UIImage {
/**
:name: width
*/
public var width: CGFloat {
return size.width
}
/**
:name: height
*/
public var height: CGFloat {
return size.height
}
/**
:name: internalResize
*/
private func internalResize(var toWidth w: CGFloat = 0, var toHeight h: CGFloat = 0) -> UIImage? {
if 0 < w {
h = height * w / width
} else if 0 < h {
w = width * h / height
}
let g: UIImage?
let t: CGRect = CGRectMake(0, 0, w, h)
UIGraphicsBeginImageContext(t.size)
drawInRect(t, blendMode: .Normal, alpha: 1)
g = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return g
}
/**
:name: resize
*/
public func resize(toWidth w: CGFloat) -> UIImage? {
return internalResize(toWidth: w)
}
/**
:name: resize
*/
public func resize(toHeight h: CGFloat) -> UIImage? {
return internalResize(toHeight: h)
}
}
......@@ -27,7 +27,8 @@ class ViewController: UIViewController {
// Examples of using CardView.
// Uncomment different examples and read
// the comments below.
prepareGeneralCardView()
// prepareGeneralCardView()
prepareCardViewWithoutDivider()
}
/**
......@@ -84,5 +85,47 @@ class ViewController: UIViewController {
MaterialLayout.alignToParentHorizontally(view, child: cardView, left: 20, right: 20)
}
/**
:name: prepareCardViewWithoutDivider
:description: An example of the CardView without the divider line between buttons.
*/
private func prepareCardViewWithoutDivider() {
let cardView: CardView = CardView()
cardView.divider = false
cardView.backgroundColor = MaterialColor.teal.darken1
// Title label.
let titleLabel: UILabel = UILabel()
titleLabel.text = "Data-Driven"
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.mediumWithSize(24)
cardView.titleLabel = titleLabel
// Detail label
let detailLabel: UILabel = UILabel()
detailLabel.text = "Build scalable data-driven apps with GraphKit."
detailLabel.textColor = MaterialColor.white
detailLabel.numberOfLines = 0
cardView.detailLabel = detailLabel
// Favorite button.
let img1: UIImage? = UIImage(named: "ic_favorite_white")
let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.white
btn1.pulseFill = true
btn1.pulseScale = false
btn1.setImage(img1, forState: .Normal)
btn1.setImage(img1, forState: .Highlighted)
// Add buttons to right side.
cardView.rightButtons = [btn1]
// To support orientation changes, use MaterialLayout.
view.addSubview(cardView)
cardView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTop(view, child: cardView, top: 100)
MaterialLayout.alignToParentHorizontally(view, child: cardView, left: 20, right: 20)
}
}
......@@ -16,13 +16,15 @@ MaterialKit is on CocoaPods under the name [MK](https://cocoapods.org/?q=MK).
One of Material Design's greatest additions to UI is the NavigationBarView. In the Examples folder, you can checkout some code to get you started with this wonderful component.
![MaterialKitNavigationBarView](http://www.materialkit.io/github/MaterialKitNavigationBarView.gif)
![MaterialKitNavigationBarView](http://www.materialkit.io/MK/MaterialKitNavigationBarView.gif)
### CardView
Right out of the box to a fully customized configuration, CardView always stands out. Take a look at a few examples in action and find more in the Examples directory.
![MaterialKitCardView](http://www.materialkit.io/github/MaterialKitCardView.gif)
![MaterialKitCardView](http://www.materialkit.io/MK/MaterialKitCardView.gif)
![MaterialKitCardViewDataDriven](http://www.materialkit.io/MK/MaterialKitCardViewDataDriven.gif)
### License
......
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