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

Swift 4.2 Updates #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Sources/Filters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MetaballFilter : CIFilter {
guard let inputImage = inputImage else { return nil }

// color
var image = CIFilter(name: "CIColorControls", parameters: [kCIInputBrightnessKey: 1, kCIInputSaturationKey: 0, kCIInputContrastKey: 0, kCIInputImageKey: inputImage])?.outputImage
var image = CIFilter(name: "CIColorControls", withInputParameters: [kCIInputBrightnessKey: 1, kCIInputSaturationKey: 0, kCIInputContrastKey: 0, kCIInputImageKey: inputImage])?.outputImage

// blur
image = image?.applyingGaussianBlur(sigma: Double(blurRadius))
Expand Down
8 changes: 4 additions & 4 deletions Sources/Slider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,19 @@ open class Slider : UIControl {

private func layoutBackgroundImage() {
let inset = UIEdgeInsets(top: min(0, shadowOffset.height - shadowBlur), left: min(0, shadowOffset.width - shadowBlur), bottom: max(0, shadowOffset.height + shadowBlur) * -1, right: max(0, shadowOffset.width + shadowBlur) * -1)
backgroundImageView.frame = self.bounds.inset(by: inset)
backgroundImageView.frame = UIEdgeInsetsInsetRect(self.bounds, inset)
backgroundImageView.image = UIGraphicsImageRenderer(bounds: backgroundImageView.bounds).image(actions: { context in
if let color = shadowColor {
context.cgContext.setShadow(offset: shadowOffset, blur: shadowBlur, color: color.cgColor)
}
contentViewColor?.setFill()
let inset = UIEdgeInsets(top: inset.top * -1, left: inset.left * -1, bottom: inset.bottom * -1, right: inset.right * -1)
UIBezierPath(roundedRect: backgroundImageView.bounds.inset(by: inset), cornerRadius: contentViewCornerRadius).fill()
UIBezierPath(roundedRect: UIEdgeInsetsInsetRect(backgroundImageView.bounds, inset), cornerRadius: contentViewCornerRadius).fill()
})
}

private func layoutValueView() {
let bounds = self.contentView.bounds.inset(by: UIEdgeInsets(top: 0, left: valueViewMargin, bottom: 0, right: valueViewMargin))
let bounds = UIEdgeInsetsInsetRect(self.contentView.bounds, UIEdgeInsets(top: 0, left: valueViewMargin, bottom: 0, right: valueViewMargin))
let centerX = fraction * bounds.size.width + bounds.minX
setValueViewPositionX(to: centerX)
}
Expand Down Expand Up @@ -319,7 +319,7 @@ open class Slider : UIControl {
}

private func boundsForValueViewCenter() -> CGRect {
return bounds.inset(by: UIEdgeInsets(top: 0, left: valueViewMargin - ValueView.kLayoutMarginInset + valueView.bounds.midX, bottom: 0, right: valueViewMargin - ValueView.kLayoutMarginInset + valueView.bounds.midX))
return UIEdgeInsetsInsetRect(bounds, UIEdgeInsets(top: 0, left: valueViewMargin - ValueView.kLayoutMarginInset + valueView.bounds.midX, bottom: 0, right: valueViewMargin - ValueView.kLayoutMarginInset + valueView.bounds.midX))
}

private func fractionForPositionX(_ x: CGFloat) -> CGFloat {
Expand Down