Code Monkey home page Code Monkey logo

jxmarqueeview's Introduction

JXMarqueeView

languages platform cocoapods

A powerful and easy to use marquee view. He moving here. I am best.

Features

  • Automatically start marquee. (When the content beyond size, marquee start automatically.)
  • Support UIView an its subclasses. (More than just UILabel, you can customize the view to turn on the marquee effect.)

Preview

JXMarqueeType.left:From right to left

left.gif

JXMarqueeType.right:From left to right

right.gif

JXMarqueeType.reverse:reverse

reverse.gif

Requirements

  • XCode 9.0+
  • Swift 5.0+ (greater or equal 0.0.8 version)

Installation

  1. Manually
    • Download source code, drag JXMarqueeView.swift file into your project.
  2. Cocoapods
use_frameworks!
target '<Your Target Name>' do
    pod 'JXMarqueeView'
end

Usage

  • contentMargin

The interval between two views,default is 12.

  • frameInterval

Assiagned to CADisplayLink frameInterval property,default is 1.

  • pointsPerFrame

How many points each time for callback of CADisplayLink.The bigger the faster.

  • contentView

The view your need to marquee.

  • SizeToFit

When you customize complex content view, you need override func sizeThatFits(_ size: CGSize) -> CGSize,and return you correct content size.

Use case

//text
let label = UILabel()
label.textColor = UIColor.red
label.font = UIFont.systemFont(ofSize: 30, weight: .medium)
label.text = "abcdefghijklmnopqrstuvwxyz"

marqueeView.contentView = label
marqueeView.contentMargin = 50
marqueeView.marqueeType = .left
self.view.addSubview(marqueeView)

//picture
let imageView = UIImageView(image: UIImage(named: "haizeiwang.jpeg"))
imageView.contentMode = .scaleAspectFill

marqueeView.contentView = imageView
marqueeView.marqueeType = .reverse
self.view.addSubview(marqueeView)

Customize

The default implementation of contentView's copy using code:

let archivedData = NSKeyedArchiver.archivedData(withRootObject: self)
let copyView = NSKeyedUnarchiver.unarchiveObject(with: archivedData) as! UIView

But if the view has cornerRadius、shadow, the copyView will lose it. So you should implement protocol JXMarqueeViewCopyable function func copyMarqueeView() -> UIView. Just return a new instance UIView. Just checkout CustomCopyView.swift in example.

Picture case preview

picture.gif

Custom case preview

poetry.gif

jxmarqueeview's People

Contributors

pujiaxin33 avatar zohairhadi avatar nuomi1 avatar

Watchers

James Cloos 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.