From 4fec72f016bdbb859e7c2c809202a2aa5fe514d6 Mon Sep 17 00:00:00 2001 From: Luca Mozzarelli Date: Mon, 6 Feb 2017 16:48:14 +0100 Subject: [PATCH] The body UILabel is now a UITextView (for future link support) Updated podspec file --- LMArticleViewController.podspec | 4 +-- .../LMArticleViewController.m | 36 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/LMArticleViewController.podspec b/LMArticleViewController.podspec index 994ce3b..dcc6755 100644 --- a/LMArticleViewController.podspec +++ b/LMArticleViewController.podspec @@ -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." @@ -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" diff --git a/LMArticleViewController/LMArticleViewController.m b/LMArticleViewController/LMArticleViewController.m index cd01099..4fdc50c 100644 --- a/LMArticleViewController/LMArticleViewController.m +++ b/LMArticleViewController/LMArticleViewController.m @@ -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; @@ -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 @@ -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; } @@ -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 { @@ -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