Skip to content

Commit

Permalink
change README
Browse files Browse the repository at this point in the history
  • Loading branch information
zsk425 committed Jan 12, 2015
1 parent b730a60 commit d8a69c9
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# OS
.DS_Store

# Xcode
#
build/
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ pod "SKTagView"

### Usage

#### Example
Check out the project. It contains the usage of normal and in UITableViewCell.

#### Code
```objc
- (void)setupTagView
{
Expand Down Expand Up @@ -55,8 +59,12 @@ When use with UITableViewCell in multi-line mode,it MUST be set preferredMaxLayo
### Screenshot
#### Normal
![](https://raw.github.com/zsk425/SKTagView/master/Screenshots/example.png)
#### With UITableViewCell
![](https://raw.github.com/zsk425/SKTagView/master/Screenshots/example2.png)
### License
AFNetworking is available under the MIT license. See the LICENSE file for more info.
Binary file added Screenshots/example2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion WrapViewWithAutolayout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
682ABA7E1A36933300D57A1A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 682ABA7C1A36933300D57A1A /* LaunchScreen.xib */; };
682ABA8A1A36933300D57A1A /* WrapViewWithAutolayoutTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 682ABA891A36933300D57A1A /* WrapViewWithAutolayoutTests.m */; };
682ABA951A3693BC00D57A1A /* SKTagView.m in Sources */ = {isa = PBXBuildFile; fileRef = 682ABA941A3693BC00D57A1A /* SKTagView.m */; };
D865CB921A6415B200F3592C /* TagsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D865CB911A6415B200F3592C /* TagsTableViewController.m */; };
D865CB951A64160500F3592C /* TagsTableCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D865CB941A64160500F3592C /* TagsTableCell.m */; };
E198833B70106A7B969AF9D2 /* SKTag.m in Sources */ = {isa = PBXBuildFile; fileRef = E198883D944B29B6488A5B34 /* SKTag.m */; };
E1988E0CF76D59E86E94A7CC /* SKTagButton.m in Sources */ = {isa = PBXBuildFile; fileRef = E1988DC652E4B5A7DD3FC44D /* SKTagButton.m */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -48,6 +50,10 @@
682ABA931A3693BC00D57A1A /* SKTagView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKTagView.h; sourceTree = "<group>"; };
682ABA941A3693BC00D57A1A /* SKTagView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKTagView.m; sourceTree = "<group>"; };
6B8DAFE5AC7C5EAB149408DB /* Pods-WrapViewWithAutolayout.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WrapViewWithAutolayout.release.xcconfig"; path = "Pods/Target Support Files/Pods-WrapViewWithAutolayout/Pods-WrapViewWithAutolayout.release.xcconfig"; sourceTree = "<group>"; };
D865CB901A6415B200F3592C /* TagsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagsTableViewController.h; sourceTree = "<group>"; };
D865CB911A6415B200F3592C /* TagsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TagsTableViewController.m; sourceTree = "<group>"; };
D865CB931A64160500F3592C /* TagsTableCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagsTableCell.h; sourceTree = "<group>"; };
D865CB941A64160500F3592C /* TagsTableCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TagsTableCell.m; sourceTree = "<group>"; };
E19884C2F2577114719748BD /* SKTagButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKTagButton.h; sourceTree = "<group>"; };
E198883D944B29B6488A5B34 /* SKTag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKTag.m; sourceTree = "<group>"; };
E1988A206257CAF7FE6FC77A /* SKTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKTag.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -103,9 +109,13 @@
682ABA741A36933300D57A1A /* ViewController.h */,
682ABA751A36933300D57A1A /* ViewController.m */,
682ABA771A36933300D57A1A /* Main.storyboard */,
682ABA7A1A36933300D57A1A /* Images.xcassets */,
682ABA7C1A36933300D57A1A /* LaunchScreen.xib */,
682ABA7A1A36933300D57A1A /* Images.xcassets */,
682ABA6D1A36933300D57A1A /* Supporting Files */,
D865CB901A6415B200F3592C /* TagsTableViewController.h */,
D865CB911A6415B200F3592C /* TagsTableViewController.m */,
D865CB931A64160500F3592C /* TagsTableCell.h */,
D865CB941A64160500F3592C /* TagsTableCell.m */,
);
path = WrapViewWithAutolayout;
sourceTree = "<group>";
Expand Down Expand Up @@ -303,8 +313,10 @@
buildActionMask = 2147483647;
files = (
682ABA761A36933300D57A1A /* ViewController.m in Sources */,
D865CB951A64160500F3592C /* TagsTableCell.m in Sources */,
682ABA731A36933300D57A1A /* AppDelegate.m in Sources */,
682ABA951A3693BC00D57A1A /* SKTagView.m in Sources */,
D865CB921A6415B200F3592C /* TagsTableViewController.m in Sources */,
682ABA701A36933300D57A1A /* main.m in Sources */,
E198833B70106A7B969AF9D2 /* SKTag.m in Sources */,
E1988E0CF76D59E86E94A7CC /* SKTagButton.m in Sources */,
Expand Down
52 changes: 46 additions & 6 deletions WrapViewWithAutolayout/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C94b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="FbG-4l-pGh">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
<viewController storyboardIdentifier="ViewController" id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Be7-f3-ZyA">
<rect key="frame" x="130" y="497" width="60" height="30"/>
<rect key="frame" x="270" y="529" width="60" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="a9z-2k-Bwd"/>
</constraints>
Expand All @@ -35,11 +35,51 @@
<constraint firstItem="2fi-mo-0CV" firstAttribute="top" secondItem="Be7-f3-ZyA" secondAttribute="bottom" constant="41" id="rMS-bS-fsk"/>
</constraints>
</view>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="490" y="472"/>
<point key="canvasLocation" x="520" y="94"/>
</scene>
<!--Tags Table View Controller-->
<scene sceneID="tt9-lj-mO1">
<objects>
<tableViewController storyboardIdentifier="TagsTableViewController" id="FbG-4l-pGh" customClass="TagsTableViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="Wr1-1i-w0o">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="TagsTableCell" id="m3R-h8-kmN" customClass="TagsTableCell">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="m3R-h8-kmN" id="nn6-mE-tbH">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xsy-ND-UuT" customClass="SKTagView">
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</subviews>
<constraints>
<constraint firstItem="xsy-ND-UuT" firstAttribute="top" secondItem="nn6-mE-tbH" secondAttribute="top" id="9kr-5O-Ik5"/>
<constraint firstAttribute="bottom" secondItem="xsy-ND-UuT" secondAttribute="bottom" id="Vln-Rh-viI"/>
<constraint firstAttribute="trailing" secondItem="xsy-ND-UuT" secondAttribute="trailing" id="pf1-IY-gKZ"/>
<constraint firstItem="xsy-ND-UuT" firstAttribute="leading" secondItem="nn6-mE-tbH" secondAttribute="leading" id="uzI-Y2-76L"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="tagView" destination="xsy-ND-UuT" id="flf-6f-XWB"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="FbG-4l-pGh" id="T8r-k0-JAd"/>
<outlet property="delegate" destination="FbG-4l-pGh" id="WQc-dz-8cY"/>
</connections>
</tableView>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Iv9-aI-L7R" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="520" y="788"/>
</scene>
</scenes>
</document>
14 changes: 14 additions & 0 deletions WrapViewWithAutolayout/TagsTableCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// TagsTableCell.h
// WrapViewWithAutolayout
//
// Created by Shaokang Zhao on 15/1/12.
// Copyright (c) 2015年 shiweifu. All rights reserved.
//

#import <UIKit/UIKit.h>

@class SKTagView;
@interface TagsTableCell : UITableViewCell
@property (weak, nonatomic) IBOutlet SKTagView *tagView;
@end
23 changes: 23 additions & 0 deletions WrapViewWithAutolayout/TagsTableCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// TagsTableCell.m
// WrapViewWithAutolayout
//
// Created by Shaokang Zhao on 15/1/12.
// Copyright (c) 2015年 shiweifu. All rights reserved.
//

#import "TagsTableCell.h"

@implementation TagsTableCell

- (void)awakeFromNib {
// Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

@end
13 changes: 13 additions & 0 deletions WrapViewWithAutolayout/TagsTableViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// TagsTableViewController.h
// WrapViewWithAutolayout
//
// Created by Shaokang Zhao on 15/1/12.
// Copyright (c) 2015年 shiweifu. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface TagsTableViewController : UITableViewController

@end
96 changes: 96 additions & 0 deletions WrapViewWithAutolayout/TagsTableViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//
// TagsTableViewController.m
// WrapViewWithAutolayout
//
// Created by Shaokang Zhao on 15/1/12.
// Copyright (c) 2015年 shiweifu. All rights reserved.
//

#import "TagsTableViewController.h"
#import "TagsTableCell.h"
#import "SKTag.h"
#import "SKTagView.h"
#import <HexColors/HexColor.h>

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)

//Cell
static NSString *const kTagsTableCellReuseIdentifier = @"TagsTableCell";

@interface TagsTableViewController ()
@property (nonatomic, strong) NSArray *colorPool;
@end

@implementation TagsTableViewController

- (void)viewDidLoad {
[super viewDidLoad];

self.colorPool = @[@"#7ecef4", @"#84ccc9", @"#88abda",@"#7dc1dd",@"#b6b8de"];

self.tableView.tableFooterView = [UIView new];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}

- (void)configureCell:(TagsTableCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
cell.tagView.preferredMaxLayoutWidth = SCREEN_WIDTH;
cell.tagView.padding = UIEdgeInsetsMake(12, 12, 12, 12);
cell.tagView.insets = 15;
cell.tagView.lineSpace = 10;

[cell.tagView.subviews enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) {
[obj removeFromSuperview];
}];

//添加Tags
[@[@"Python", @"Javascript", @"HTML", @"Go", @"Objective-C",@"C", @"PHP"] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)
{
SKTag *tag = [SKTag tagWithText:obj];
tag.textColor = [UIColor whiteColor];
tag.fontSize = 15;
tag.padding = UIEdgeInsetsMake(13.5, 12.5, 13.5, 12.5);
tag.bgColor = [UIColor colorWithHexString:self.colorPool[idx % self.colorPool.count]];
tag.target = self;
tag.action = @selector(handleBtn:);
tag.cornerRadius = 5;

[cell.tagView addTag:tag];
}];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TagsTableCell *cell = [tableView dequeueReusableCellWithIdentifier:kTagsTableCellReuseIdentifier forIndexPath:indexPath];
[self configureCell:cell atIndexPath:indexPath];

return cell;
}

#pragma mark - Table view delegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
TagsTableCell *cell = nil;
if (!cell) {
cell = [tableView dequeueReusableCellWithIdentifier:kTagsTableCellReuseIdentifier];
}

[self configureCell:cell atIndexPath:indexPath];
return [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height + 1;
}

#pragma mark - User interactions
- (void)handleBtn:(id)sender
{
NSLog(@"Tapped me");
}

@end

0 comments on commit d8a69c9

Please sign in to comment.