Skip to content

A video play button with animation of iQiYi and YouKu, thanks for mengxianliang

License

Notifications You must be signed in to change notification settings

LaudyLaw/LSPlayPauseButton

Repository files navigation

LSPlayPauseButton

English

Overview

This project is a swift version of XLPlayButton thanks for XianLiang Meng

The play&pause button include style of iQiYi and YouKu

Usage

The LSPlayPauseButton is a sub class of UIButton, you can use the normal initiate method:

let button = LSPlayPauseButton(frame: CGRect(x: 0, y: 0, width: 60, height: 60), style: .youku, state: .play)

You can also use lazy init method

let button = LSPlayPauseButton(frame: CGRect(x: 0, y: 0, width: 60, height: 60))

The lazy version use style of iQiYi as default style and pause state as the default state of the button. (You must expicity init the frame since the animation will use the frame size)

You change the button's state use the buttonState property change the state of the button

button.buttonState = .play

or

button.buttonState = .pause

Installation with CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target 'TargetName' do
use_frameworks!
pod 'LSPlayPauseButton'
end

中文

简介

这是一个使用Swift重写的 XLPlayButton, 感谢XianLiang Meng

LSPlayPauseButton包含了爱奇艺优酷两种国内常见的播放暂停按钮的app端动画展示

使用方法

LSPlayPauseButton继承自UIKit的UIButton类,你可以使用完整初始化方法

let button = LSPlayPauseButton(frame: CGRect(x: 0, y: 0, width: 60, height: 60), style: .youku, state: .play)

你也可以使用如下的简单初始化方法

let button = LSPlayPauseButton(frame: CGRect(x: 0, y: 0, width: 60, height: 60))

简单初始化方法以爱奇艺的样式为默认样式,以暂停状态为按钮的初始状态(初始化必须设置正确的frame参数,这是因为播放暂停按钮的动画需要根据frame的尺寸来进行设置)

使用对象的buttonState属性来对按钮的状态进行更改

button.buttonState = .play

或者

button.buttonState = .pause

使用Cocoapods进行安装

Cocoapods是一个非常方便使用三方库的工具,如果你还不知道Cocoapods,请点击Cocoapods前往查看使用方法。 在你的Podfile文件中添加

pod 'LSPlayPauseButton'