Skip to content

Commit

Permalink
changed restriction type
Browse files Browse the repository at this point in the history
  • Loading branch information
superbderrick committed Sep 11, 2017
1 parent 7008a77 commit df71ac2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion SummerSlider.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'SummerSlider'
s.version = '0.1.2'
s.version = '0.1.3'
s.summary = 'Custom UISlider library '
s.description = <<-DESC
TODO: The iOS Custom Slider library that can distinguish the parts where the advertisement of the video player comes out.
Expand Down
102 changes: 51 additions & 51 deletions SummerSlider/SummerSlider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,74 +9,74 @@
import UIKit

public class SummerSlider: UISlider {

var markColor : UIColor!
var markWidth : CGFloat!
var markPositions : Array<Float>!
var selectedBarColor : UIColor!
var unselectedBarColor : UIColor!
override init(frame: CGRect) {
super.init(frame: frame)
self.setupDefaultValues()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
fatalError("init(coder:) has not been implemented")
// self.setupDefaultValues()
}

override func draw(_ rect: CGRect) {
super.draw(rect)
var markColor : UIColor!
var markWidth : CGFloat!
var markPositions : Array<Float>!
var selectedBarColor : UIColor!
var unselectedBarColor : UIColor!
override init(frame: CGRect) {
super.init(frame: frame)
self.setupDefaultValues()
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
fatalError("init(coder:) has not been implemented")
// self.setupDefaultValues()
}
override public func draw(_ rect: CGRect) {
super.draw(rect)

// Basic Setup to make a Inner Rect.
let innerRect = rect.insetBy(dx: Constants.INNER_RECT.X, dy: Constants.INNER_RECT.Y)
UIGraphicsBeginImageContextWithOptions(innerRect.size ,false , 0)
let context = UIGraphicsGetCurrentContext()!
let innerRect = rect.insetBy(dx: Constants.INNER_RECT.X, dy: Constants.INNER_RECT.Y)
UIGraphicsBeginImageContextWithOptions(innerRect.size ,false , 0)
let context = UIGraphicsGetCurrentContext()!

// Draw Selection Rect.
SummerSlider.drawRect(context, innerRect , self.selectedBarColor.cgColor)
// Make Selection Image.
let selectedSide = UIGraphicsGetImageFromCurrentImageContext()
selectedSide!.resizableImage(withCapInsets: UIEdgeInsets.zero)
let selectedSide = UIGraphicsGetImageFromCurrentImageContext()
selectedSide!.resizableImage(withCapInsets: UIEdgeInsets.zero)
// Draw UNSelection Rect.
SummerSlider.drawRect(context, innerRect , self.unselectedBarColor.cgColor)
// Make UNSelection Image.
let unSelectedSide = UIGraphicsGetImageFromCurrentImageContext()
unSelectedSide!.resizableImage(withCapInsets: UIEdgeInsets.zero)
let unSelectedSide = UIGraphicsGetImageFromCurrentImageContext()
unSelectedSide!.resizableImage(withCapInsets: UIEdgeInsets.zero)
// Draw Selection Image.
selectedSide!.draw(at: CGPoint(x:0,y:0))
selectedSide!.draw(at: CGPoint(x:0,y:0))
// Draw Selection Marks.
SummerSlider.drawMarks(context, innerRect, self.markColor.cgColor, self.markPositions, self.markWidth)


let selectedStripSide = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero)
SummerSlider.drawMarks(context, innerRect, self.markColor.cgColor, self.markPositions, self.markWidth)
let selectedStripSide = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero)
// Draw UNSelection Image.
unSelectedSide!.draw(at: CGPoint(x:0,y:0))
unSelectedSide!.draw(at: CGPoint(x:0,y:0))



SummerSlider.drawMarks(context, innerRect, self.markColor.cgColor, self.markPositions, self.markWidth)

let unselectedStripSide = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero)
UIGraphicsEndImageContext()
setupTrackRange(selectedStripSide, unselectedStripSide)
}
let unselectedStripSide = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero)
UIGraphicsEndImageContext()
setupTrackRange(selectedStripSide, unselectedStripSide)
}


private func setupTrackRange(_ selectedStripSide:UIImage , _ unselectedStripSide:UIImage) {
self.setMinimumTrackImage(selectedStripSide, for: UIControlState.normal)
self.setMaximumTrackImage(unselectedStripSide, for: UIControlState.normal)
self.setMaximumTrackImage(unselectedStripSide, for: UIControlState.normal)
}

private func setupDefaultValues(){
Expand Down Expand Up @@ -109,5 +109,5 @@ public class SummerSlider: UISlider {
context.setStrokeColor(rectColr)
context.strokePath()
}

}

0 comments on commit df71ac2

Please sign in to comment.