From df71ac2097bdad42f9b4ee7b26c4e4d6e09958d7 Mon Sep 17 00:00:00 2001 From: derrick Date: Mon, 11 Sep 2017 21:11:34 +0900 Subject: [PATCH] changed restriction type --- SummerSlider.podspec | 2 +- SummerSlider/SummerSlider.swift | 102 ++++++++++++++++---------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/SummerSlider.podspec b/SummerSlider.podspec index e8b736a..03c3a9d 100644 --- a/SummerSlider.podspec +++ b/SummerSlider.podspec @@ -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. diff --git a/SummerSlider/SummerSlider.swift b/SummerSlider/SummerSlider.swift index 469249f..a791ac5 100644 --- a/SummerSlider/SummerSlider.swift +++ b/SummerSlider/SummerSlider.swift @@ -9,74 +9,74 @@ import UIKit public class SummerSlider: UISlider { - - var markColor : UIColor! - var markWidth : CGFloat! - var markPositions : Array! - 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! + 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(){ @@ -109,5 +109,5 @@ public class SummerSlider: UISlider { context.setStrokeColor(rectColr) context.strokePath() } - + }