Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to use images, fixed warnings #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import CoreGraphics
@objc optional func progressBar(_ progressBar: FlexibleSteppedProgressBar,
canSelectItemAtIndex index: Int) -> Bool

@objc optional func progressBar(_ progressBar: FlexibleSteppedProgressBar,
textAtIndex index: Int, position: FlexibleSteppedProgressBarTextLocation) -> String
@objc optional func progressBar(_ progressBar: FlexibleSteppedProgressBar, textAtIndex index: Int, position: FlexibleSteppedProgressBarTextLocation) -> String

@objc optional func progressBar(_ progressBar: FlexibleSteppedProgressBar, selectedTextAtIndex index: Int, position: FlexibleSteppedProgressBarTextLocation) -> UIImage?

}

Expand Down Expand Up @@ -61,6 +62,7 @@ import CoreGraphics

open var currentSelectedCenterColor: UIColor = UIColor.black
open var currentSelectedTextColor: UIColor!
open var currentSelectedCenterTextColor: UIColor! = UIColor.black
open var viewBackgroundColor: UIColor = UIColor.white
open var selectedOuterCircleStrokeColor: UIColor!
open var lastStateOuterCircleStrokeColor: UIColor!
Expand Down Expand Up @@ -455,6 +457,11 @@ import CoreGraphics
textLayer.string = "\(i)"
}

if let image = self.delegate?.progressBar?(self, selectedTextAtIndex: i, position: .center), i < currentIndex {
textLayer.contents = image.cgImage
textLayer.contentsGravity = kCAGravityResizeAspect
}

textLayer.sizeWidthToFit()

textLayer.frame = CGRect(x: centerPoint.x - textLayer.bounds.width/2, y: centerPoint.y - textLayer.bounds.height/2, width: textLayer.bounds.width, height: textLayer.bounds.height)
Expand Down Expand Up @@ -491,6 +498,11 @@ import CoreGraphics
textLayer.string = "\(i)"
}

if let image = self.delegate?.progressBar?(self, selectedTextAtIndex: i, position: .top), i < currentIndex {
textLayer.contents = image.cgImage
textLayer.contentsGravity = kCAGravityResizeAspect
}

textLayer.sizeWidthToFit()

textLayer.frame = CGRect(x: centerPoint.x - textLayer.bounds.width/2, y: centerPoint.y - textLayer.bounds.height/2 - _progressRadius - textDistance, width: textLayer.bounds.width, height: textLayer.bounds.height)
Expand Down Expand Up @@ -521,6 +533,11 @@ import CoreGraphics
textLayer.string = "\(i)"
}

if let image = self.delegate?.progressBar?(self, selectedTextAtIndex: i, position: .bottom), i < currentIndex {
textLayer.contents = image.cgImage
textLayer.contentsGravity = kCAGravityResizeAspect
}

textLayer.sizeWidthToFit()

textLayer.frame = CGRect(x: centerPoint.x - textLayer.bounds.width/2, y: centerPoint.y - textLayer.bounds.height/2 + _progressRadius + textDistance, width: textLayer.bounds.width, height: textLayer.bounds.height)
Expand Down Expand Up @@ -633,33 +650,33 @@ import CoreGraphics

xCursor = centerPoint.x

startAngle = CGFloat(M_PI)
startAngle = CGFloat(Double.pi)
endAngle = -angle

} else if(i < nbPoint - 1) {

startAngle = CGFloat(M_PI) + angle
startAngle = CGFloat(Double.pi) + angle
endAngle = -angle

} else if(i == (nbPoint - 1)){

startAngle = CGFloat(M_PI) + angle
startAngle = CGFloat(Double.pi) + angle
endAngle = 0

} else if(i == nbPoint) {

startAngle = 0
endAngle = CGFloat(M_PI) - angle
endAngle = CGFloat(Double.pi) - angle

} else if (i < (2 * nbPoint - 1)) {

startAngle = angle
endAngle = CGFloat(M_PI) - angle
endAngle = CGFloat(Double.pi) - angle

} else {

startAngle = angle
endAngle = CGFloat(M_PI)
endAngle = CGFloat(Double.pi)

}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one more occurrence of M_PI in this file. Please replace it too.


Expand Down