Skip to content

Commit

Permalink
Fix access modifier bug(Previous version is not properly set. So libr…
Browse files Browse the repository at this point in the history
…ary doesn't work.)

Change demo gif files
  • Loading branch information
DingdingKim committed Jun 26, 2017
1 parent a4f64be commit e1ec3f2
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 99 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
40 changes: 20 additions & 20 deletions DDViewSwitcher/DDImageSwitcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

import UIKit

class DDImageSwitcher: UIView {
open class DDImageSwitcher: UIView {

private var imgCenter = UIImageView()
private var imgNext = UIImageView()

public var isScrolling = false
public var isAutoScroll = true
public var isInfiniteScrolling = true
open var isScrolling = false
open var isAutoScroll = true
open var isInfiniteScrolling = true

public var arrData = [String]()
open var arrData = [String]()

//Index of current data
var indexSwitcher: Int = 0
open var indexSwitcher: Int = 0

//Default value of animation
public var duration = 1.0
public var delay = 1.0
open var duration = 1.0
open var delay = 1.0

public var scrollDirection: ScrollDirection = .vertical
open var scrollDirection: ScrollDirection = .vertical

public enum ScrollDirection: String {
case horizontral = "horizontral"
Expand Down Expand Up @@ -55,8 +55,8 @@ class DDImageSwitcher: UIView {
}

//Action when view is tapped
public var tapAction: ((Void) -> Void)?
public var finishScrollAction: ((Void) -> Void)?
open var tapAction: ((Void) -> Void)?
open var finishScrollAction: ((Void) -> Void)?

public init(frame: CGRect, data: [String], scrollDirection: ScrollDirection) {
super.init(frame: frame)
Expand All @@ -76,7 +76,7 @@ class DDImageSwitcher: UIView {
}

//Initiallize switcher view. set default values.
func initSwitcher(){
private func initSwitcher(){
self.removeFromSuperview()

clipsToBounds = true
Expand All @@ -102,7 +102,7 @@ class DDImageSwitcher: UIView {
}

//Scroll stop
func stop(){
open func stop(){
if(isAutoScroll){
isScrolling = false
}
Expand All @@ -112,7 +112,7 @@ class DDImageSwitcher: UIView {
}

//Scroll start
func start(){
open func start(){
if(isAutoScroll){
isScrolling = true
updateSwitcherAnimation()
Expand All @@ -123,7 +123,7 @@ class DDImageSwitcher: UIView {
}

//Scroll reset
func reset(){
open func reset(){
indexSwitcher = 0
self.imgCenter.frame.origin = pointNormal
self.imgNext.frame.origin = (self.scrollDirection == .vertical) ? self.pointVerticalOverBottom : self.pointHorizontalOverRight
Expand All @@ -134,7 +134,7 @@ class DDImageSwitcher: UIView {
}

//Animate to next text
func next(){
open func next(){
if(isAutoScroll){
debugPrint("DDTextSwitcherLabel >> You can't call next() method. 'isAutoScroll' value is true")
}
Expand All @@ -144,13 +144,13 @@ class DDImageSwitcher: UIView {
}

//Set UIImageView contentMode
public func setContentMode(contentMode: UIViewContentMode) {
open func setContentMode(contentMode: UIViewContentMode) {
imgCenter.contentMode = contentMode
imgNext.contentMode = contentMode
}

//****************************
func updateSwitcherAnimation() {
open func updateSwitcherAnimation() {
UIView.animate(withDuration: duration, delay: delay, options: [], animations: { () -> Void in

self.imgCenter.frame.origin = (self.scrollDirection == .vertical) ? self.pointVerticalOverTop : self.pointHorizontalOverLeft
Expand Down Expand Up @@ -193,13 +193,13 @@ class DDImageSwitcher: UIView {
}

//Tap action handler
func didTap(sender: UITapGestureRecognizer) {
open func didTap(sender: UITapGestureRecognizer) {
guard let action = self.tapAction else { return /*didn't set closure*/}
action()
}

//scroll finish(Only isInfiniteScrolling is false) action handler
func finishScroll() {
open func finishScroll() {
guard let action = self.finishScrollAction else { return /*didn't set closure*/}
action()
}
Expand Down
62 changes: 31 additions & 31 deletions DDViewSwitcher/DDTextSwitcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@

import UIKit

class DDTextSwitcher: UIView {
open class DDTextSwitcher: UIView {

private var lbCenter = UILabel()
private var lbNext = UILabel()

public var isScrolling = false
public var isAutoScroll = true
public var isInfiniteScrolling = true

public var arrData = [String]()
open var isScrolling = false
open var isAutoScroll = true
open var isInfiniteScrolling = true

open var arrData = [String]()

//Index of current data
var indexSwitcher: Int = 0
open var indexSwitcher: Int = 0

//Default value of animation
public var duration = 1.0
public var delay = 1.0

public var scrollDirection: ScrollDirection = .vertical
open var duration = 1.0
open var delay = 1.0
open var scrollDirection: ScrollDirection = .vertical

public enum ScrollDirection: String {
case horizontal = "horizontal"
case vertical = "vertical"
}

private var pointVerticalOverTop: CGPoint{
return CGPoint(x: 0, y: -self.frame.height)
}

private var pointVerticalOverBottom: CGPoint{
return CGPoint(x: 0, y: self.frame.height)
}

private var pointHorizontalOverLeft: CGPoint{
return CGPoint(x: -self.frame.width, y: 0)
}
Expand All @@ -54,13 +54,13 @@ class DDTextSwitcher: UIView {
return CGPoint(x: 0, y: 0)
}

public var currentText: String {
open var currentText: String {
return lbCenter.text!
}

//Action when view is tapped
public var tapAction: ((Void) -> Void)?
public var finishScrollAction: ((Void) -> Void)?
open var tapAction: ((Void) -> Void)?
open var finishScrollAction: ((Void) -> Void)?

public init(frame: CGRect, data: [String], scrollDirection: ScrollDirection) {
super.init(frame: frame)
Expand All @@ -80,7 +80,7 @@ class DDTextSwitcher: UIView {
}

//Initiallize switcher view. set default values.
func initSwitcher(){
private func initSwitcher(){
self.removeFromSuperview()

clipsToBounds = true
Expand Down Expand Up @@ -112,7 +112,7 @@ class DDTextSwitcher: UIView {
}

//Scroll stop
func stop(){
open func stop(){
if(isAutoScroll){
isScrolling = false
}
Expand All @@ -122,7 +122,7 @@ class DDTextSwitcher: UIView {
}

//Scroll start
func start(){
open func start(){
if(isAutoScroll){
isScrolling = true
updateSwitcherAnimation()
Expand All @@ -133,7 +133,7 @@ class DDTextSwitcher: UIView {
}

//Scroll reset
func reset(){
open func reset(){
indexSwitcher = 0
self.lbCenter.frame.origin = pointNormal
self.lbNext.frame.origin = (self.scrollDirection == .vertical) ? self.pointVerticalOverBottom : self.pointHorizontalOverRight
Expand All @@ -142,9 +142,9 @@ class DDTextSwitcher: UIView {
indexSwitcher += 1
lbNext.text = arrData[indexSwitcher]
}

//Animate to next text
func next(){
open func next(){
if(isAutoScroll){
debugPrint("DDTextSwitcherLabel >> You can't call next() method. 'isAutoScroll' value is true")
}
Expand All @@ -154,31 +154,31 @@ class DDTextSwitcher: UIView {
}

//Set UILabel text color
public func setTextColor(color: UIColor) {
open func setTextColor(color: UIColor) {
lbCenter.textColor = color
lbNext.textColor = color
}

//Set UILabel text size
public func setTextSize(size: CGFloat) {
open func setTextSize(size: CGFloat) {
lbCenter.font = lbCenter.font.withSize(size)
lbNext.font = lbNext.font.withSize(size)
}

//Set UILabel text alignment
public func setTextAlignment(align: NSTextAlignment) {
open func setTextAlignment(align: NSTextAlignment) {
lbCenter.textAlignment = align
lbNext.textAlignment = align
}

//Set UILabel number of Lines
public func setNumberOfLines(numberOfLines: Int) {
open func setNumberOfLines(numberOfLines: Int) {
lbCenter.numberOfLines = 0
lbNext.numberOfLines = 0
}

//****************************
func updateSwitcherAnimation() {
private func updateSwitcherAnimation() {
UIView.animate(withDuration: duration, delay: delay, options: [], animations: { () -> Void in

self.lbCenter.frame.origin = (self.scrollDirection == .vertical) ? self.pointVerticalOverTop : self.pointHorizontalOverLeft
Expand All @@ -191,7 +191,7 @@ class DDTextSwitcher: UIView {
if(self.isInfiniteScrolling) {
self.indexSwitcher = 0
}
//Scroll is end
//Scroll is end
else {
self.indexSwitcher = self.indexSwitcher + 1
self.lbCenter.text = self.lbNext.text
Expand All @@ -213,7 +213,7 @@ class DDTextSwitcher: UIView {

self.lbCenter.frame.origin = self.pointNormal
self.lbNext.frame.origin = (self.scrollDirection == .vertical) ? self.pointVerticalOverBottom : self.pointHorizontalOverRight

//This case is stop() is called.
if(self.isScrolling){
self.updateSwitcherAnimation()
Expand All @@ -222,13 +222,13 @@ class DDTextSwitcher: UIView {
}

//Tap action handler
func didTap(sender: UITapGestureRecognizer) {
open func didTap(sender: UITapGestureRecognizer) {
guard let action = self.tapAction else { return /*didn't set closure*/}
action()
}

//scroll finish(Only isInfiniteScrolling is false) action handler
func finishScroll() {
open func finishScroll() {
guard let action = self.finishScrollAction else { return /*didn't set closure*/}
action()
}
Expand Down
Loading

0 comments on commit e1ec3f2

Please sign in to comment.