Skip to content

Commit

Permalink
Support settings tags color.
Browse files Browse the repository at this point in the history
  • Loading branch information
lijingcheng committed Aug 12, 2015
1 parent 53f8f19 commit 2cd27cc
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Example/JCTagListView/JCViewController.m
Expand Up @@ -22,6 +22,8 @@ - (void)viewDidLoad
[super viewDidLoad];

self.tagListView.canSeletedTags = YES;
self.tagListView.tagColor = [UIColor blueColor];
self.tagListView.tagCornerRadius = 5.0f;

[self.tagListView.tags addObjectsFromArray:@[@"NSString", @"NSMutableString", @"NSArray", @"UIAlertView", @"UITapGestureRecognizer", @"IBOutlet", @"IBAction", @"id", @"UIView", @"UIStatusBar", @"UITableViewController", @"UIStepper", @"UISegmentedControl", @"UICollectionViewController", @"UISearchBar", @"UIToolbar", @"UIPageControl", @"UIActionSheet", @"NSMutableArray", @"NSDictionary", @"NSMutableDictionary", @"NSSet", @"NSMutableSet", @"NSData", @"NSMutableData", @"NSDate", @"NSCalendar", @"UIButton", @"UILabel", @"UITextField", @"UITextView", @"UIImageView", @"UITableView", @"UICollectionView", @"UIViewController"]];

Expand Down
4 changes: 2 additions & 2 deletions JCTagListView.podspec
Expand Up @@ -9,8 +9,8 @@

Pod::Spec.new do |s|
s.name = "JCTagListView"
s.version = "0.0.3"
s.summary = "Support delete tags."
s.version = "0.0.4"
s.summary = "Support delete tags and settings tags color."
s.homepage = "http://lijingcheng.github.io/"
# s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2"
s.license = 'MIT'
Expand Down
2 changes: 1 addition & 1 deletion Pod/Classes/JCTagCell.h
Expand Up @@ -10,6 +10,6 @@

@interface JCTagCell : UICollectionViewCell

@property (nonatomic, copy) NSString *title;
@property (nonatomic, strong) UILabel *titleLabel;

@end
16 changes: 0 additions & 16 deletions Pod/Classes/JCTagCell.m
Expand Up @@ -8,25 +8,16 @@

#import "JCTagCell.h"

@interface JCTagCell ()

@property (nonatomic, strong) UILabel *titleLabel;

@end

@implementation JCTagCell

- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
self.layer.cornerRadius = 10.0f;
self.layer.masksToBounds = YES;
self.layer.borderWidth = 1.0f;
self.layer.borderColor = [UIColor darkGrayColor].CGColor;

self.titleLabel = [[UILabel alloc] initWithFrame:self.bounds];
self.titleLabel.textAlignment = NSTextAlignmentCenter;
self.titleLabel.textColor = [UIColor darkGrayColor];
self.titleLabel.font = [UIFont systemFontOfSize:14.0f];
[self.contentView addSubview:self.titleLabel];
}
Expand All @@ -48,11 +39,4 @@ - (void)prepareForReuse
self.titleLabel.text = @"";
}

- (void)setTitle:(NSString *)title
{
_title = title;

self.titleLabel.text = title;
}

@end
3 changes: 3 additions & 0 deletions Pod/Classes/JCTagListView.h
Expand Up @@ -12,6 +12,9 @@ typedef void (^JCTagListViewBlock)(NSInteger index);

@interface JCTagListView : UIView

@property (nonatomic, strong) UIColor *tagColor;
@property (nonatomic, assign) CGFloat tagCornerRadius;

@property (nonatomic, assign) BOOL canSeletedTags;

@property (nonatomic, strong) NSMutableArray *tags;
Expand Down
8 changes: 7 additions & 1 deletion Pod/Classes/JCTagListView.m
Expand Up @@ -51,6 +51,9 @@ - (void)setup

self.tags = [NSMutableArray array];

self.tagColor = [UIColor darkGrayColor];
self.tagCornerRadius = 10.0f;

JCCollectionViewTagFlowLayout *layout = [[JCCollectionViewTagFlowLayout alloc] init];

self.collectionView = [[UICollectionView alloc] initWithFrame:self.bounds collectionViewLayout:layout];
Expand Down Expand Up @@ -89,7 +92,10 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
{
JCTagCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
cell.backgroundColor = [UIColor whiteColor];
cell.title = self.tags[indexPath.item];
cell.layer.borderColor = self.tagColor.CGColor;
cell.layer.cornerRadius = self.tagCornerRadius;
cell.titleLabel.text = self.tags[indexPath.item];
cell.titleLabel.textColor = self.tagColor;

return cell;
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -5,7 +5,7 @@
[![License](https://img.shields.io/cocoapods/l/JCTagListView.svg?style=flat)](http://cocoapods.org/pods/JCTagListView)
[![Platform](https://img.shields.io/cocoapods/p/JCTagListView.svg?style=flat)](http://cocoapods.org/pods/JCTagListView)

Support delete tags.
Support delete tags and settings tags color.

<img width="320" src="./ScreenShot.png">

Expand Down

0 comments on commit 2cd27cc

Please sign in to comment.