GithubHelp home page GithubHelp logo

carabina / gravitytagcloudview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from billypchan/gravitytagcloudview

0.0 1.0 0.0 12.05 MB

A tag cloud view with gravity.

License: MIT License

Ruby 24.86% Swift 72.89% Objective-C 2.25%

gravitytagcloudview's Introduction

GravityTagCloudView

A tag cloud view with gravity for iOS. It is a rewritten version of https://github.com/zhangao0086/DKTagCloudView in swift 3 with UIdynamics gravity support (Thanks for this nice tutorial for UI dynamics - https://www.bignerdranch.com/blog/uidynamics-in-swift/).

You may play around GravityTagCloudView on Apptize.

Fill some bugs in the iPhone SE screen:

(To measure the performance of UIDynamic, you may include konoma/fps-counter in your project.)

Playground example:

Play with random font size:

PNG

Play with weighted font size and fill the entire view with tags:

PNG

///TODO: gif

///TODO: example for no gravity, random font size

How To Get Started

Installation with CocoaPods

Edit your Podfile and add DKTagCloudView, (TODO add to offical pod spec):

pod 'GravityTagCloudView', '~> 0.2.0'

Add import GravityTagCloudView to the top of classes that will use it.

Create instances (Also supports xib/storyboard) :

let gravityTagCloudView = GravityTagCloudView()

gravityTagCloudView.frame = CGRect(x: 0, y: 0, width: 360, height: 200)

self.view.addSubview(gravityTagCloudView)

Setup items:

If you want the size of the label is propertional to their weight, please set labelSizeType properties to kWeighted and assign array to titleWeights:

gravityTagCloudView.labelSizeType = .weighted
gravityTagCloudView.titleWeights = [["title":"elephant", "weight":10],
                                    ["title":"cow", "weight":7],
                                    ["title":"horse", "weight":7],
                                    ["title":"dog", "weight":5],
                                    ["title":"cat", "weight":3],
                                    ["title":"rat", "weight":1],
                                    ["title":"mouse", "weight":1],
                                    ]

Generates:

gravityTagCloudView.generate()

Callback

gravityTagCloudView.tagClickBlock = { title, tag -> Void in       
  print("tag =\(tag), title=\(title)")
}

Customized:

/**

 *  Label size option. Defautls to random.
 */
public var labelSizeType : LabelSizeType = .random

/**
 *  Gravity enabled?
 */
public var isGravity : Bool = true

/**
 *  Min font size. Defautls to 14.
 */
public var minFontSize : Float = 14

/**
 *  Max font size. Defaults to 60.
 */
public var maxFontSize : Float = 60

/**
 *  Random text colors with default list
 */
public var randomColors = [UIColor.black, UIColor.cyan, UIColor.purple, UIColor.orange, UIColor.red, UIColor.yellow, UIColor.lightGray, UIColor.gray, UIColor.green]

License

This code is distributed under the terms and conditions of the MIT license.

gravitytagcloudview's People

Contributors

billypchan avatar

Watchers

Carabineiro 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.