GithubHelp home page GithubHelp logo

tbxark / tkdotsegment Goto Github PK

View Code? Open in Web Editor NEW
105.0 5.0 9.0 91 KB

TKDotSegment is a segment with dot animation

Home Page: http://tbxark.site

License: MIT License

Swift 90.63% Ruby 4.91% Objective-C 4.46%
swift cocoapods carthage segment ios-animation widget

tkdotsegment's Introduction

TKDotSegment

A segment with dot animation

Swift Version License MIT CocoaPods CocoaPods Carthage compatible Support

Requirements

  • iOS 8.0+
  • Xcode 9.0
  • Swift 4.0

Installation

CocoaPods

You can use CocoaPods to install TKDotSegment by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!
pod 'TKDotSegment'

To get the full benefits import TKDotSegment wherever you import UIKit

import UIKit
import TKDotSegment

Carthage

Create a Cartfile that lists the framework and run carthage update. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/TKDotSegment.framework to an iOS project.

github "tbxark/TKDotSegment"

Manually

  1. Download and drop TKDotSegmentControl.swift in your project.
  2. Congratulations!

Usage example


let titles = ["First", "Second", "Third", "Fourth"]
let  segment = TKDotSegmentControl(titles: titles, frame: CGRect(x: 0, y: 0, width: 300, height: 40))
segment.dotColor = UIColor(red:1,  green:0.539,  blue:0.490, alpha:1)
segment.selectTitleColor = UIColor(red:1,  green:0.539,  blue:0.490, alpha:1)
segment.numOfDot = 4
segment.dotSpace = 6
segment.clickAction = { (index: Int, changeOffset: Bool) in
    print("Segment Select Index: \(index)")
}

Base

变量名 描述 Description
titles 选项标题 segment title
numOfDot 圆点数目 dot count
dotDiameter 圆点直径 dot diameter
dotSpace 圆点间距(负数则自动计算) dot space(automatic calculation when value is a positive number)
dotColor 圆点颜色 dot color
selectTitleColor 标题被选中时的颜色 The color of the title is selected
unSelectTitleColor 标题未被选中时的颜色 The color of the title is not selected
titleFont 标题字体 The font of the title
PLDot 圆点(可重写drawRect来自定义形状) Override drawRect to customize shape

1 . 改变 Index (change index)

    func changeSelectedIndex(index: Int, animate: Bool = true)

2 . 接受 Index 变化事件 (index value change event)

TKDotSegmentAction = (index: Int,  internaliFlag: Bool) -> Void

index 被选择的 index (selected index)

internaliFlag 是否内部点击触发的标志位 (event by click flag)

3 . 自定义圆点形状(Custom dot shape)

重写PLDotdrawRect 方法就可以了

Overwrite the drawRect of PLDot

Release History

  • 1.4.0 Support swift 4.0

  • 1.3.1 Support swift 3.0

  • 1.0.2 Complete basic functions, add Cocoapod and Carthage support

Contribute

We would love for you to contribute to TKDotSegment, check the LICENSE file for more info.

Meta

TBXark – @tbxark[email protected]

Distributed under the MIT license. See LICENSE for more information.

https://github.com/TBXark

tkdotsegment's People

Contributors

tbxark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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