Skip to content

Commit

Permalink
Add spacing property to TTGTextTagCollectionView
Browse files Browse the repository at this point in the history
  • Loading branch information
zekunyan committed Jan 4, 2016
1 parent 4b851ab commit ce094fe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Example/TTGTagCollectionView/TTGExample1ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ - (void)viewDidLoad {

// Style1
_textTagCollectionView1.tagTextFont = [UIFont boldSystemFontOfSize:22.0f];
_textTagCollectionView1.horizontalSpacing = 6.0;
_textTagCollectionView1.verticalSpacing = 12.0;

// Style2
_textTagCollectionView2.tagTextFont = [UIFont systemFontOfSize:14.0f];
Expand Down
4 changes: 4 additions & 0 deletions Pod/Classes/TTGTextTagCollectionView.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
@property (assign, nonatomic) CGFloat tagBorderWidth;
@property (strong, nonatomic) UIColor *tagBorderColor;

// Space
@property (assign, nonatomic) CGFloat horizontalSpacing;
@property (assign, nonatomic) CGFloat verticalSpacing;

- (void)addTag:(NSString *)tag;

- (void)addTags:(NSArray <NSString *> *)tags;
Expand Down
15 changes: 15 additions & 0 deletions Pod/Classes/TTGTextTagCollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ - (void)commonInit {
_tagBorderWidth = 1.0f;
_tagBorderColor = [UIColor lightGrayColor];

_horizontalSpacing = 4.0f;
_verticalSpacing = 4.0f;

_tagCollectionView = [TTGTagCollectionView new];
_tagCollectionView.delegate = self;
_tagCollectionView.dataSource = self;
Expand Down Expand Up @@ -258,6 +261,18 @@ - (void)setEnableTagSelection:(BOOL)enableTagSelection {
[self refreshAllLabels];
}

- (void)setHorizontalSpacing:(CGFloat)horizontalSpacing {
_horizontalSpacing = horizontalSpacing;
_tagCollectionView.horizontalSpacing = horizontalSpacing;
[_tagCollectionView reload];
}

- (void)setVerticalSpacing:(CGFloat)verticalSpacing {
_verticalSpacing = verticalSpacing;
_tagCollectionView.verticalSpacing = verticalSpacing;
[_tagCollectionView reload];
}

#pragma mark - Private methods

- (void)refreshAllLabels {
Expand Down

0 comments on commit ce094fe

Please sign in to comment.