Skip to content

Commit

Permalink
Address the issue: Tags in the single row example are not vertical ce…
Browse files Browse the repository at this point in the history
…ntered #8

``paragraphStyle.lineSpacing = 5.0;`` doesn't work well in the single
row.
  • Loading branch information
weijentu committed Apr 11, 2017
1 parent ae2a524 commit b2afdf3
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ObjC/AutomaticHeightTagTableViewCell/Views/AHTagView.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ - (void)setupConstraints {
toItem:self
attribute:NSLayoutAttributeTop
multiplier:1.0
constant:3.0]];
constant:6.0]];

[constraints addObject:[NSLayoutConstraint constraintWithItem:self
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:_label
attribute:NSLayoutAttributeBottom
multiplier:1.0
constant:3.0]];
constant:6.0]];

[NSLayoutConstraint activateConstraints:constraints];
}
Expand Down
4 changes: 0 additions & 4 deletions ObjC/AutomaticHeightTagTableViewCell/Views/AHTagsLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ - (void)setTags:(NSArray<AHTag *> *)tags {
[mutableString endEditing];
}

NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.lineSpacing = 5.0;
[mutableString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, mutableString.length)];

self.attributedText = mutableString;
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/* An initialization sample of AHTag with Swift 3.0 */
let tag = AHTag(category: "Genre",
title: "Classical",
color: UIColor(red: 0.626, green: 0.56, blue: 1, alpha: 1),
color: UIColor(red: 0.626, green: 0.56, blue: 1, alpha: 1),
URL: NSURL(string: "http://itunes.com"),
enabled: true)
```
Expand Down
4 changes: 2 additions & 2 deletions Swift/AutomaticHeightTagTableViewCell/Views/AHTagView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ class AHTagView: UIView {
toItem: self,
attribute: .top,
multiplier: 1,
constant: 3))
constant: 6))
constraints.append(NSLayoutConstraint(item: self,
attribute: .bottom,
relatedBy: .equal,
toItem: self.label,
attribute: .bottom,
multiplier: 1,
constant: 3))
constant: 6))
NSLayoutConstraint.activate(constraints)
}

Expand Down
5 changes: 0 additions & 5 deletions Swift/AutomaticHeightTagTableViewCell/Views/AHTagsLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ class AHTagsLabel: UILabel {
mutableString.endEditing()
}

let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 5
mutableString.addAttribute(NSParagraphStyleAttributeName,
value: paragraphStyle,
range: NSRange(location: 0, length: mutableString.length))
self.attributedText = mutableString
}

Expand Down
Binary file modified images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b2afdf3

Please sign in to comment.