UIViewController subclass to beautifully present news articles and blog posts.

Overview

LMArticleViewController

License Platform Version

This framework allows you to create Apple News-inspired UIViewControllers with ease.

It is heavily inspired by MRArticleViewController, in fact the core is a simple translation of it. However I added some features I thought could be useful.
Preview 1 Preview 2

Features

The layout is shown in the images above, here's some extra features.

Animations

  • The navigation bar shrinks when you scroll down.
  • The image view stretches when the scrollview bounces ( just like Facebook's Instant Articles).

Appereance

  • You can set custom fonts for all the text.
  • Supports NSAttributedString in the body.
  • Supports automatic background color and automatic light/dark text color.

Installation

LMArticleViewController is available through CocoaPods. Simply add the following line to your Podfile.

pod 'LMArticleViewController'

Usage

You can either subclass LMArticleViewController and set the contents in the viewDidLoad: method or instantiate an LMArticleViewController object, set its properties and present it.

Case A: Subclass

- (void)viewDidLoad {

    // Set custom fonts
    // Size doesn't matter here, the super class overrides with default values
    [self setHeadlineFont:[UIFont fontWithName:@"Nexa Bold" size:1]];
    [self setAuthorFont:[UIFont fontWithName:@"Roboto-Regular" size:1]];
    [self setDateFont:[UIFont fontWithName:@"Roboto-Regular" size:1]];

    // Set contents
    self.headline       = self.dataDictionary[k_TITLE];
    self.image          = self.dataDictionary[k_IMAGE];
    self.author         = self.dataDictionary[k_AUTHOR];
    self.attributedBody = self.dataDictionary[k_BODY];
    self.date           = self.dataDictionary[k_DATE];

    // IMPORTANT! Setup must happen before [super viewDidLoad]!!
    [super viewDidLoad];

}

Case B: Init and push

- (void)openArticleWithContents:(NSDictionary *)dataDictionary {

    LMArticleViewController* articleViewController = [[LMArticleViewController alloc]init];

    [articleViewController setBodyFont:[UIFont fontWithName:@"Roboto-Medium" size:1]];

    articleViewController.headline       = dataDictionary[k_TITLE];
    articleViewController.image          = dataDictionary[k_IMAGE];
    articleViewController.author         = dataDictionary[k_AUTHOR];
    articleViewController.attributedBody = dataDictionary[k_BODY];
    articleViewController.date           = dataDictionary[k_DATE];

    [self.navigationController pushViewController:articleViewController animated:YES];
}

To-Do List

  • Adjust image view size and proportions.
You might also like...
MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.
MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.

MZFormSheetPresentationController MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding sup

Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView.
Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView.

StepProgressView Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView. Usage let progr

High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton, Promise and more.

SwiftyUI High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton and more. Features SwiftyView GPU rendering Image and Color

UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS
UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen
BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen

BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen. It is especially well

Custom segue for OSX Storyboards with slide and cross fade effects (NSViewControllerTransitionOptions)
Custom segue for OSX Storyboards with slide and cross fade effects (NSViewControllerTransitionOptions)

CustomSegue Custom segue for OSX Storyboards. Slide and cross fade effects, new customized window. class MyViewController: NSViewController { overr

Fashion is your helper to share and reuse UI styles in a Swifty way.
Fashion is your helper to share and reuse UI styles in a Swifty way.

Fashion is your helper to share and reuse UI styles in a Swifty way. The main goal is not to style your native apps in CSS, but use a set

Beautiful flag icons for usage in apps and on the web.
Beautiful flag icons for usage in apps and on the web.

FlagKit Beautiful flag icons for usage in apps and on the web. All flags are provided as stand-alone PNG and SVG files. FlagKit also provides an Asset

UIView and CGRect extension that adds properties to manipulate them efficiently

Geometry Geometry is a UIView and CGRect extension that lets you work with view and rect geometry easier. It adds the following properties to UIView:

Comments
  • Image not found

    Image not found

    The README.md file does not contain the images that is meant to be there. This following line shows that images should be attached in the README.md:

    The layout is shown in the images above, here's some extra features.

    opened by vincentneo 1
Owner
Luca Mozzarelli
Luca Mozzarelli
Newly is a drop in solution to add Twitter/Facebook/Linkedin style, new updates/tweets/posts available button

Newly is a drop in solution to add Twitter/Facebook/Linkedin style, new updates/tweets/posts available button. It can be used to notify user about new content availability and can other actions can be triggers using its delegate method.

Dhiraj Rajendra Jadhao 197 Sep 22, 2022
A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI.

BetterSafariView A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI. Contents Motivation Requirements U

Dongkyu Kim 392 Dec 31, 2022
iOS custom controller used in Jobandtalent app to present new view controllers as cards

CardStackController iOS custom controller used in the Jobandtalent app to present new view controllers as cards. This controller behaves very similar

jobandtalent 527 Dec 15, 2022
A UINavigationController subclass that support pop interactive UINavigationbar with hidden or show.

KDInteractiveNavigationController Features ✨ UINavigationController interactive with UINavigationBar hidden or show Hide all UINavigationController ba

Kingiol 154 Dec 3, 2022
A UITextView subclass that adds support for multiline placeholder written in Swift.

KMPlaceholderTextView A UITextView subclass that adds support for multiline placeholder written in Swift. Usage You can set the value of the placehold

Zhouqi Mo 794 Jan 7, 2023
A UIControl subclass that makes it easy to create empty states.

AZEmptyState Making empty state simple. Screenshots Installation Cocoa Pods: pod 'AZEmptyState' Manual: Simply drag and drop the Sources folder to you

Antonio Zaitoun 88 Oct 2, 2022
IHTypeWriterLabel - A simple, UILabel subclass which poulates itself as if being typed

IHTypeWriterLabel A simple, UILabel subclass which poulates itself as if being typed. HighLights Written purely in SWIFT. Very simple and lightweight.

Md Ibrahim Hassan 24 May 7, 2019
Fetch the star wars api from all the planets and list and show details using Swift UI and Combine

Star Wars Planets Fetch the star wars planet data by using stat war api, list and show details using SwiftUI and Combine frameworks ?? Swift UI Framew

null 1 Aug 10, 2022
A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView and iPhone X safe area support for content reloading. Built for iOS 10 and later.

Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f

Putra Z. 43 Feb 4, 2022
🏞 A simple iOS photo and video browser with optional grid view, captions and selections written in Swift5.0

Introduction ?? MediaBrowser can display one or more images or videos by providing either UIImage objects, PHAsset objects, or URLs to library assets,

Kyle Yi 631 Dec 29, 2022