Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
The body UILabel is now a UITextView (for future link support)
Browse files Browse the repository at this point in the history
Updated podspec file
  • Loading branch information
lucamozzarelli committed Feb 6, 2017
1 parent ffde209 commit 4fec72f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions LMArticleViewController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Pod::Spec.new do |s|


s.name = "LMArticleViewController"
s.version = "1.1"
s.version = "1.2"
s.summary = "An Objective-C subclass of UIViewController inspired by Apple News"
s.description = "This subclass of UIViewController provides an article view controller with one top image, title, date, author and body labels."

Expand All @@ -14,7 +14,7 @@ Pod::Spec.new do |s|

s.platform = :ios, "9.0"

s.source = { :git => "https://github.com/lucamozza/LMArticleViewController.git", :tag => 'v1.1'}
s.source = { :git => "https://github.com/lucamozza/LMArticleViewController.git", :tag => 'v1.2'}

s.source_files = "LMArticleViewController", "LMArticleViewController/**/*.{h,m}"
# s.exclude_files = "Classes/Exclude"
Expand Down
36 changes: 18 additions & 18 deletions LMArticleViewController/LMArticleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ @interface LMArticleViewController () {
@property (strong, nonatomic) UILabel *authorLabel;
@property (strong, nonatomic) UILabel *dateLabel;
@property (strong, nonatomic) UIView *divider;
@property (strong, nonatomic) UILabel *bodyLabel;
@property (strong, nonatomic) UITextView *bodyTextView;
@property (strong, nonatomic) NSLayoutConstraint *heightConstraint;
@property (strong, nonatomic) NSLayoutConstraint *topConstraint;
@property (assign, nonatomic) CGFloat lastContentOffset;
Expand Down Expand Up @@ -212,29 +212,29 @@ - (void)setupDate {

- (void)setupBody {

self.bodyLabel.translatesAutoresizingMaskIntoConstraints = false;
[self.backgroundView addSubview:self.bodyLabel];
self.bodyTextView.translatesAutoresizingMaskIntoConstraints = false;
[self.backgroundView addSubview:self.bodyTextView];

NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self.bodyLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.dateLabel attribute:NSLayoutAttributeBottom multiplier:1 constant:20];
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self.bodyTextView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.dateLabel attribute:NSLayoutAttributeBottom multiplier:1 constant:20];
constraint.active = YES;

constraint = [NSLayoutConstraint constraintWithItem:self.bodyLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.backgroundView attribute:NSLayoutAttributeLeft multiplier:1 constant:14];
constraint = [NSLayoutConstraint constraintWithItem:self.bodyTextView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.backgroundView attribute:NSLayoutAttributeLeft multiplier:1 constant:14];
constraint.active = YES;

constraint = [NSLayoutConstraint constraintWithItem:self.bodyLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.backgroundView attribute:NSLayoutAttributeRight multiplier:1 constant:-14];
constraint = [NSLayoutConstraint constraintWithItem:self.bodyTextView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.backgroundView attribute:NSLayoutAttributeRight multiplier:1 constant:-14];
constraint.active = YES;

constraint = [NSLayoutConstraint constraintWithItem:self.bodyLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.backgroundView attribute:NSLayoutAttributeBottom multiplier:1 constant:-30];
constraint = [NSLayoutConstraint constraintWithItem:self.bodyTextView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.backgroundView attribute:NSLayoutAttributeBottom multiplier:1 constant:-30];
constraint.active = YES;


self.bodyLabel.numberOfLines = 0;
self.bodyTextView.scrollEnabled = NO;

if (!self.bodyFont)
self.bodyLabel.font = [UIFont fontWithName:@"Georgia" size:20];
self.bodyTextView.font = [UIFont fontWithName:@"Georgia" size:20];
else
self.bodyLabel.font = [self.bodyFont fontWithSize:20];
[self.bodyLabel sizeToFit];
self.bodyTextView.font = [self.bodyFont fontWithSize:20];
[self.bodyTextView sizeToFit];
}

// Properties setters
Expand Down Expand Up @@ -283,12 +283,12 @@ - (void)setDateString:(NSString *)dateString {

- (void)setBody:(NSString *)body {
_body = body;
self.bodyLabel.text = body;
self.bodyTextView.text = body;
}

- (void)setAttributedBody:(NSAttributedString *)attributedBody {
_attributedBody = attributedBody;
self.bodyLabel.attributedText = attributedBody;
self.bodyTextView.attributedText = attributedBody;
_body = attributedBody.string;
}

Expand Down Expand Up @@ -320,7 +320,7 @@ - (void)setAuthorColor:(UIColor *)authorColor {
- (void)setBodyColor:(UIColor *)bodyColor {
_bodyColor = bodyColor;
bodyColorSet = YES;
self.bodyLabel.textColor = bodyColor;
self.bodyTextView.textColor = bodyColor;
}

- (void)setTextColor:(UIColor *)textColor {
Expand Down Expand Up @@ -373,10 +373,10 @@ - (UILabel *)dateLabel {
return _dateLabel;
}

- (UILabel *)bodyLabel {
if (!_bodyLabel)
_bodyLabel = [UILabel new];
return _bodyLabel;
- (UITextView *)bodyTextView {
if (!_bodyTextView)
_bodyTextView = [UITextView new];
return _bodyTextView;
}

// Animation
Expand Down

0 comments on commit 4fec72f

Please sign in to comment.