Slider thumb with shadow frame calculation fix

This commit is contained in:
Anton Popkov 2018-12-10 18:44:27 +03:00
parent 918edbd74f
commit 1165323ea3
1 changed files with 4 additions and 10 deletions

View File

@ -464,19 +464,13 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
let thumbSizeForStyle = thumbSizeIncludingShadow()
let thumbWidth = thumbSizeForStyle.width
let thumbHeight = thumbSizeForStyle.height
let rectangle = CGRect(x:thumbAbscissa - (thumbWidth / 2),
y: (frame.height - thumbHeight)/2,
width: thumbWidth,
height: thumbHeight)
let shadowRadius = (thumbComponentStyle == .iOS) ? iOSThumbShadowRadius : thumbShadowRadius
let shadowOffset = (thumbComponentStyle == .iOS) ? iOSThumbShadowOffset : thumbShadowOffset
thumbLayer.frame = ((shadowRadius != 0.0) // Ignore offset if there is no shadow
? rectangle.insetBy(dx: shadowRadius + shadowOffset.width,
dy: shadowRadius + shadowOffset.height)
: rectangle.insetBy(dx: shadowRadius,
dy: shadowRadius))
thumbLayer.frame = CGRect(x:thumbAbscissa - (thumbWidth / 2),
y: (frame.height - thumbHeight)/2,
width: thumbWidth,
height: thumbHeight)
switch thumbComponentStyle {
case .rounded: // A rounded thumb is circular