Git Product home page Git Product logo

wangyingbo / mrarticleviewcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrigdon-zz/mrarticleviewcontroller

0.0 2.0 0.0 3.8 MB

王颖博-这个框架允许您轻松地设置展示新闻文章视图控制器,只要简单的设置一些字段,就可以轻松的展示很好的阅读体验。Easily create UIViewControllers for news articles similar to those in the News app.

License: MIT License

Swift 56.40% Ruby 4.39% Objective-C 2.46% Shell 36.76%

mrarticleviewcontroller's Introduction

MRArticleViewController

CI Status Version License Platform

This framework allows you to easily setup View Controllers to display News Articles inspired by those from the Apple News App. Simply set the required fields and run, and you will have a nice looking view for your articles.

Preview Preview Preview

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Swift 3: use v1.0.6
  • Swift 2: use v0.2.0

Installation

MRArticleViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MRArticleViewController'

Usage

  1. Import the module
import MRArticleViewController
  1. Subclass ArticleViewController
class ViewController: ArticleViewController
  1. In viewDidLoad, set the following required properties before super.viewDidLoad():
override func viewDidLoad() {
    // required
    image = UIImage(named: "pulpfiction")!
    headline = "LA gangsters witness supposed \"Divine Intervention\""
    author = "Quentin Tarantino"
    date = NSDate()
    body = bodyText

    super.viewDidLoad()
}
  1. Optional: In viewDidLoad, set the following optional properties before super.viewDidLoad():
...

// Uses the algorithm from UIImageColors to extract the colors from the image and color the
// background, headline, author, date, and body accordingly. Defaults to false, but highly
// recommended to set to true. More on this feature below.
autoColored = true

// If you don't like the autoColor feature, you can also color each component individually
backgroundColor = UIColor.blackColor()
headlineColor = UIColor.yellowColor()
authorColor = UIColor.orangeColor()
dateColor = UIColor.grayColor()
bodyColor = UIColor.grayColor()

super.viewDidLoad()

Done! 🍻

More on autoColored

This library leverages the algorithm from UIImageColors. Setting autoColor = true extracts the colors from the image and applies the

  • background color to the background
  • the primary color to the headline
  • the detail color to the date and body
  • and the secondary color to the author.

Note that UIImageColors is not a dependency, the code has just been ported into this library.

To-do

Want a feature you don't see? Submit an issue and I'll add it to the to-do list, or hack it yourself and submit a pull request.

  • Add new styles
  • Swift package manager

Author

Matthew Rigdon, [email protected]

License

MRArticleViewController is available under the MIT license. See the LICENSE file for more info. Please also refer to Panic's original license for the autoColor feature.

mrarticleviewcontroller's People

Watchers

王颖博 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.