Compare commits

..

15 Commits

Author SHA1 Message Date
Ivan Vorobei 0d1381d941 Update to 1.4.8
Change logic for dismiss controller when scroll down in `UIScrollView`.
2019-02-19 20:01:53 +03:00
Ivan Vorobei 39c30a030d Update SPStorkController.podspec 2019-02-19 12:31:58 +03:00
Ivan Vorobei 9e4f6e086f Update to 1.4.6
Added dismiss trigger when scrollView is scrolling down. Also added `swipeToDismissEnabled` checking to allow scrollView bounce when `swipeToDismissEnabled` is disabled.
2019-02-19 12:17:46 +03:00
Ivan Vorobei 5bc31cdc57 Merge pull request #37 from ilia3546/master
Added dismiss trigger when scrollView is scrolling down. Also added `swipeToDismissEnabled` checking to allow scrollView bounce when `swipeToDismissEnabled` is disabled.
2019-02-19 12:05:30 +03:00
Ilya Kharlamov 7d53ed31e6 Fix 2019-02-18 14:26:57 +03:00
Ilya Kharlamov 80806de694 Fix 2019-02-18 14:20:58 +03:00
Ilya Kharlamov 8d8458cc34 Revert "Custom width;"
This reverts commit dd2b29f27a.
2019-02-18 13:58:19 +03:00
Ilya Kharlamov 6e09df910e Custom width;
Ability to disable snapshot scaling;
2019-02-18 13:50:00 +03:00
Ilya Kharlamov 253f60cfa9 ScrollView with disabled swipeToDismissEnabled fixed;
Added trigger for dismissing when view is scrolling down;
2019-02-18 13:10:29 +03:00
Ivan Vorobei 81ed7b01cd Fix some bugs
Fix bug when present 2 or more controllers with custom heights. Also fix bug with grade for `presentingController` view.
2019-02-14 00:23:35 +03:00
Ivan Vorobei d0f120d49c Remove old code 2019-02-09 15:04:10 +03:00
Ivan Vorobei bc3555e715 Update README.md 2019-02-09 09:50:20 +03:00
Ivan Vorobei 432a1206cf Update README.md 2019-02-09 09:48:04 +03:00
Ivan Vorobei 488b19fc46 Update README.md 2019-02-09 09:29:22 +03:00
Ivan Vorobei edc2b6ea41 Fix example of table view 2019-02-09 09:27:13 +03:00
78 changed files with 1035 additions and 890 deletions
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -21,7 +21,7 @@ class Controller: UIViewController {
self.presentTableControllerButton.addTarget(self, action: #selector(self.presentModalTableViewController), for: .touchUpInside)
self.presentTableControllerButton.sizeToFit()
self.presentTableControllerButton.center.x = self.view.frame.width / 2
self.presentTableControllerButton.frame.origin.y = self.presentControllerButton.frame.bottomYPosition + 10
self.presentTableControllerButton.frame.origin.y = self.presentControllerButton.frame.bottomY + 10
self.view.addSubview(self.presentTableControllerButton)
}
@@ -28,14 +28,28 @@ public struct SPStorkController {
if let presentationController = controller.presentationController as? SPStorkPresentationController {
let translation = -(scrollView.contentOffset.y + scrollView.contentInset.top)
if translation >= 0 {
if controller.isBeingPresented { return }
scrollView.subviews.forEach {
$0.transform = CGAffineTransform(translationX: 0, y: -translation)
}
presentationController.setIndicator(style: scrollView.isDragging ? .line : .arrow)
if translation >= presentationController.translateForDismiss * 0.65 {
if !scrollView.isDragging {
presentationController.presentedViewController.dismiss(animated: true, completion: nil)
return
}
}
if presentationController.pan?.state != UIGestureRecognizer.State.changed {
presentationController.scrollViewDidScroll(translation)
}
} else {
presentationController.setIndicator(style: .arrow)
presentationController.scrollViewDidScroll(0)
}
}
@@ -135,8 +135,9 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
containerView.insertSubview(snapshotView, aboveSubview: self.backgroundView)
snapshotView.frame = initialFrame
snapshotView.transform = transformForSnapshotView
snapshotView.alpha = self.alpha
snapshotView.alpha = 1 - self.alpha
snapshotView.layer.cornerRadius = self.cornerRadius
snapshotView.contentMode = .top
snapshotView.layer.masksToBounds = true
rootSnapshotView = snapshotView
@@ -227,6 +228,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
containerView.insertSubview(snapshotView, aboveSubview: backgroundView)
snapshotView.frame = initialFrame
snapshotView.transform = initialTransform
snapshotView.contentMode = .top
rootSnapshotView = snapshotView
snapshotView.layer.cornerRadius = self.cornerRadius
snapshotView.layer.masksToBounds = true
@@ -234,7 +236,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
let snapshotRoundedView = UIView()
snapshotRoundedView.layer.cornerRadius = self.cornerRadius
snapshotRoundedView.layer.masksToBounds = true
snapshotRoundedView.backgroundColor = UIColor.black.withAlphaComponent(1 - self.alpha)
snapshotRoundedView.backgroundColor = UIColor.black.withAlphaComponent(self.alpha)
containerView.insertSubview(snapshotRoundedView, aboveSubview: snapshotView)
snapshotRoundedView.frame = initialFrame
snapshotRoundedView.transform = initialTransform
@@ -292,7 +294,7 @@ extension SPStorkPresentationController {
self.workGester = false
let translation = gestureRecognizer.translation(in: presentedView).y
if translation >= self.translateForDismiss {
presentedViewController.dismiss(animated: true, completion: nil)
self.presentedViewController.dismiss(animated: true, completion: nil)
} else {
self.indicatorView.style = .arrow
UIView.animate(
@@ -323,6 +325,10 @@ extension SPStorkPresentationController {
self.updateSnapshot()
}
func setIndicator(style: SPStorkIndicatorView.Style) {
self.indicatorView.style = style
}
private func updatePresentedViewForTranslation(inVerticalDirection translation: CGFloat) {
if self.startDismissing { return }
@@ -25,21 +25,14 @@ final class SPStorkPresentingAnimationController: NSObject, UIViewControllerAnim
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard let presentedViewController = transitionContext.viewController(forKey: .to) else {
return
}
guard let presentedViewController = transitionContext.viewController(forKey: .to) else { return }
let containerView = transitionContext.containerView
containerView.addSubview(presentedViewController.view)
//presentedViewController.view.frame = CGRect(x: 0, y: containerView.bounds.height, width: containerView.bounds.width, height: containerView.bounds.height)
let finalFrameForPresentedView = transitionContext.finalFrame(for: presentedViewController)
// NEW FRAMING: Testing now. Maybe correct. If remove it lines, init frame of controller will be equal container (not stork)
presentedViewController.view.frame = finalFrameForPresentedView
presentedViewController.view.frame.origin.y = containerView.bounds.height
// END NEW.
UIView.animate(
withDuration: transitionDuration(using: transitionContext),
@@ -47,7 +47,7 @@ public class SPAnimation {
withComplection completion: (() -> Void)! = {}) {
var optionsWithRepeatition = options
optionsWithRepeatition.insert([.autoreverse, .repeat])
optionsWithRepeatition.insert([.autoreverse, .repeat, .allowUserInteraction])
self.animate(
duration,
@@ -36,6 +36,14 @@ struct SPApp {
return UIApplication.shared.keyWindow?.rootViewController
}
public static var safeArea: UIEdgeInsets {
if #available(iOS 11.0, *) {
return UIApplication.shared.keyWindow?.safeArea ?? UIEdgeInsets.zero
} else {
return UIEdgeInsets.zero
}
}
public static func set(rootController: UIViewController, animatable: Bool = true) {
rootController.view.frame = UIScreen.main.bounds
@@ -28,8 +28,8 @@ struct SPAppStore {
return "https://itunes.apple.com/by/app/id" + appID
}
public static func open(appID: String) {
if let url = URL(string: "itms-apps://itunes.apple.com/app/id\(appID)"),
public static func open(app id: String) {
if let url = URL(string: "itms-apps://itunes.apple.com/app/id\(id)"),
UIApplication.shared.canOpenURL(url) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
@@ -29,7 +29,7 @@ public struct SPAudio {
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category(rawValue: convertFromAVAudioSessionCategory(AVAudioSession.Category.ambient)), mode: AVAudioSession.Mode.default)
try AVAudioSession.sharedInstance().setActive(true)
} catch {
print("SPAudio - notStopBackgroundMusic, error")
}
}
@@ -23,17 +23,29 @@ import UIKit
extension CGRect {
public var bottomXPosition: CGFloat {
public var bottomX: CGFloat {
get { return self.origin.x + self.width }
set { self.origin.x = newValue - self.width }
}
public var bottomYPosition: CGFloat {
public var bottomY: CGFloat {
get { return self.origin.y + self.height }
set { self.origin.y = newValue - self.height }
}
public var minSideSize: CGFloat {
public var minSide: CGFloat {
return min(self.width, self.height)
}
public mutating func set(width: CGFloat) {
self = CGRect.init(x: self.origin.x, y: self.origin.y, width: width, height: self.height)
}
public mutating func set(height: CGFloat) {
self = CGRect.init(x: self.origin.x, y: self.origin.y, width: self.width, height: height)
}
public mutating func set(width: CGFloat, height: CGFloat) {
self = CGRect.init(x: self.origin.x, y: self.origin.y, width: width, height: height)
}
}
@@ -70,6 +70,14 @@ extension String {
return false
}
public var isEmpty: Bool {
return (self.removeAllSpaces() == "")
}
public var words: [String] {
return components(separatedBy: .punctuationCharacters).joined().components(separatedBy: .whitespaces)
}
public mutating func replace(_ replacingString: String, with newString: String) {
self = self.replacingOccurrences(of: replacingString, with: newString)
}
@@ -39,13 +39,12 @@ extension UIAlertController {
preferredStyle: .alert
)
if cancelButtonTitle != nil {
ac.addAction(UIAlertAction.init(
title: cancelButtonTitle!,
style: UIAlertAction.Style.cancel,
handler: nil)
)
}
guard cancelButtonTitle != nil else { return }
ac.addAction(UIAlertAction.init(
title: cancelButtonTitle!,
style: UIAlertAction.Style.cancel,
handler: nil)
)
ac.addAction(UIAlertAction.init(
title: buttonTitle,
@@ -64,10 +63,8 @@ extension UIAlertController {
preferredStyle: .actionSheet
)
var style = UIAlertAction.Style.default
if isDestructive {
style = .destructive
}
let style = isDestructive ? .destructive : UIAlertAction.Style.default
ac.addAction(UIAlertAction.init(
title: buttonTitle,
style: style,
@@ -76,11 +73,10 @@ extension UIAlertController {
}))
ac.addAction(UIAlertAction.init(
title: cancelButtonTitle,
style: UIAlertAction.Style.default,
style: UIAlertAction.Style.cancel,
handler: { (action) in
complection(false)
}))
viewController.present(ac, animated: true, completion: nil)
}
}
@@ -60,8 +60,11 @@ extension UIButton {
extension UIButton {
public func setTitle(_ title: String) {
public func setTitle(_ title: String, color: UIColor? = nil) {
self.setTitle(title, for: .normal)
if let color = color {
self.setTitleColor(color)
}
}
public func setTitleColor(_ color: UIColor) {
@@ -69,6 +72,11 @@ extension UIButton {
self.setTitleColor(color.withAlphaComponent(0.7), for: .highlighted)
}
public func setImage(_ image: UIImage) {
self.setImage(image, for: .normal)
self.imageView?.contentMode = .scaleAspectFit
}
public func removeAllTargets() {
self.removeTarget(nil, action: nil, for: .allEvents)
}
@@ -111,7 +119,7 @@ extension UIButton {
}
public func hideContent(completion: (() -> Void)! = {}) {
SPAnimation.animate(0.2, animations: {
SPAnimation.animate(0.25, animations: {
self.titleLabel?.alpha = 0
}, withComplection: {
completion()
@@ -119,7 +127,7 @@ extension UIButton {
}
public func showContent(completion: (() -> Void)! = {}) {
SPAnimation.animate(0.2, animations: {
SPAnimation.animate(0.25, animations: {
self.titleLabel?.alpha = 1
}, withComplection: {
completion()
@@ -23,40 +23,39 @@ import UIKit
public extension UIFont {
public static func system(type: BoldType, size: CGFloat) -> UIFont {
return UIFont.systemFont(ofSize: size, weight: self.getBoldTypeBy(boldType: type))
public static func system(weight: FontWeight, size: CGFloat) -> UIFont {
return UIFont.systemFont(ofSize: size, weight: self.weight(for: weight))
}
@available(iOS 8.2, *)
private static func getBoldTypeBy(boldType: BoldType) -> UIFont.Weight {
switch boldType {
case .UltraLight:
private static func weight(for weight: FontWeight) -> UIFont.Weight {
switch weight {
case .ultraLight:
return UIFont.Weight.ultraLight
case .Light:
case .light:
return UIFont.Weight.light
case .Medium:
case .medium:
return UIFont.Weight.medium
case .Regular:
case .regular:
return UIFont.Weight.regular
case .Bold:
case .bold:
return UIFont.Weight.bold
case .DemiBold:
case .demiBold:
return UIFont.Weight.semibold
case .Heavy:
case .heavy:
return UIFont.Weight.heavy
default:
return UIFont.Weight.regular
}
}
public enum BoldType {
case Regular
case Medium
case Light
case UltraLight
case Heavy
case Bold
case DemiBold
case None
public enum FontWeight {
case regular
case medium
case light
case ultraLight
case heavy
case bold
case demiBold
case none
}
}
@@ -32,4 +32,12 @@ public extension UIImage {
UIGraphicsEndImageContext()
return newImage!
}
var alwaysOriginal: UIImage {
return self.withRenderingMode(.alwaysOriginal)
}
var alwaysTemplate: UIImage {
return self.withRenderingMode(.alwaysTemplate)
}
}
@@ -42,7 +42,7 @@ public extension UILabel {
self.setShadowOffsetForLetters(blurRadius: 0, widthOffset: 0, heightOffset: 0, opacity: 0)
}
public func setCenteringAlignment() {
public func setCenterAlignment() {
self.textAlignment = .center
self.baselineAdjustment = .alignCenters
}
@@ -54,7 +54,7 @@ public extension UILabel {
}
}
public func setLineSpacing(lineSpacing: CGFloat = 0.0, lineHeightMultiple: CGFloat = 0.0) {
public func setLineSpacing(_ lineSpacing: CGFloat = 0.0, lineHeightMultiple: CGFloat = 0.0) {
guard let labelText = self.text else { return }
@@ -71,7 +71,6 @@ public extension UILabel {
attributedString.addAttribute(NSAttributedString.Key.paragraphStyle, value:paragraphStyle, range:NSMakeRange(0, attributedString.length))
self.attributedText = attributedString
}
}
@@ -42,24 +42,11 @@ public extension UIView {
}
}
public func set(width: CGFloat, height: CGFloat) {
self.setHeight(height)
self.setWidth(width)
public func setBounds(_ view: UIView, withWidthFactor widthFactor: CGFloat = 1, maxWidth: CGFloat? = nil, withHeightFactor heightFactor: CGFloat = 1, maxHeight: CGFloat? = nil, withCentering: Bool = false) {
self.setBounds(view.bounds, withWidthFactor: widthFactor, maxWidth: maxWidth, withHeightFactor: heightFactor, maxHeight: maxHeight, withCentering: withCentering)
}
public func setHeight(_ height: CGFloat) {
self.frame = CGRect.init(x: self.frame.origin.x, y: self.frame.origin.y, width: self.frame.width, height: height)
}
public func setWidth(_ width: CGFloat) {
self.frame = CGRect.init(x: self.frame.origin.x, y: self.frame.origin.y, width: width, height: self.frame.height)
}
public func setEqualsFrameFromBounds(_ view: UIView, withWidthFactor widthFactor: CGFloat = 1, maxWidth: CGFloat? = nil, withHeightFactor heightFactor: CGFloat = 1, maxHeight: CGFloat? = nil, withCentering: Bool = false) {
self.setEqualsFrameFromBounds(view.bounds, withWidthFactor: widthFactor, maxWidth: maxWidth, withHeightFactor: heightFactor, maxHeight: maxHeight, withCentering: withCentering)
}
public func setEqualsFrameFromBounds(_ bounds: CGRect, withWidthFactor widthFactor: CGFloat = 1, maxWidth: CGFloat? = nil, withHeightFactor heightFactor: CGFloat = 1, maxHeight: CGFloat? = nil, withCentering: Bool = false) {
public func setBounds(_ bounds: CGRect, withWidthFactor widthFactor: CGFloat = 1, maxWidth: CGFloat? = nil, withHeightFactor heightFactor: CGFloat = 1, maxHeight: CGFloat? = nil, withCentering: Bool = false) {
var width = bounds.width * widthFactor
if maxWidth != nil { width.setIfMore(when: maxWidth!) }
@@ -75,7 +62,7 @@ public extension UIView {
}
}
public func setEqualsBoundsFromSuperview(customWidth: CGFloat? = nil, customHeight: CGFloat? = nil) {
public func setSuperviewBounds(customWidth: CGFloat? = nil, customHeight: CGFloat? = nil) {
if self.superview == nil { return }
self.frame = CGRect.init(origin: CGPoint.zero, size: self.superview!.frame.size)
if customWidth != nil {
@@ -108,15 +95,15 @@ public extension UIView {
)
}
public func setYCenteringFromSuperview() {
public func setYCenter() {
self.center.y = (self.superview?.frame.height ?? 0) / 2
}
public func setXCenteringFromSuperview() {
public func setXCenter() {
self.center.x = (self.superview?.frame.width ?? 0) / 2
}
public func setToCenterInSuperview() {
public func setToCenter() {
self.center = CGPoint.init(x: ((self.superview?.frame.width) ?? 0) / 2, y: ((self.superview?.frame.height) ?? 0) / 2)
}
}
@@ -124,7 +111,7 @@ public extension UIView {
public extension UIView {
public func setParalax(amountFactor: CGFloat) {
let amount = self.frame.minSideSize * amountFactor
let amount = self.frame.minSide * amountFactor
self.setParalax(amount: amount)
}
@@ -174,14 +161,14 @@ extension UIView {
let xTranslation = (self.frame.width - shadowWidth) / 2 + (self.frame.width * xTranslationFactor)
let yTranslation = (self.frame.height - shadowHeight) / 2 + (self.frame.height * yTranslationFactor)
let cornerRadius = self.frame.minSideSize * cornerRadiusFactor
let cornerRadius = self.frame.minSide * cornerRadiusFactor
let shadowPath = UIBezierPath.init(
roundedRect: CGRect.init(x: xTranslation, y: yTranslation, width: shadowWidth, height: shadowHeight),
cornerRadius: cornerRadius
)
let blurRadius = self.frame.minSideSize * blurRadiusFactor
let blurRadius = self.frame.minSide * blurRadiusFactor
self.layer.shadowColor = UIColor.black.cgColor
self.layer.shadowOffset = CGSize.zero
@@ -277,6 +264,6 @@ extension UIView {
}
public func round() {
self.layer.cornerRadius = self.frame.minSideSize / 2
self.layer.cornerRadius = self.frame.minSide / 2
}
}
@@ -66,7 +66,7 @@ extension SPShadow {
yTranslation = view.frame.height + maxBottomSpace - shadowHeight
}
var blurRadius = view.frame.minSideSize * blurRadiusFactor
var blurRadius = view.frame.minSide * blurRadiusFactor
blurRadius.setIfMore(when: 10)
blurRadius.setIfFewer(when: 7)
@@ -26,7 +26,7 @@ public enum SPStatusBar {
case light
}
public enum SPSystemIconType {
public enum SPSystemIcon {
case share
case close
case favorite
@@ -32,28 +32,28 @@ public class SPAppStoreActionButton: SPDownloadingButton {
switch self.style {
case .base:
self.backgroundColor = self.secondColor
self.titleLabel?.font = UIFont.system(type: .Bold, size: 14)
self.titleLabel?.font = UIFont.system(weight: .bold, size: 14)
self.contentEdgeInsets = UIEdgeInsets.init(top: 6, left: 15, bottom: 6, right: 15)
break
case .main:
self.backgroundColor = self.baseColor
self.layer.borderWidth = 0
self.setTitleColor(UIColor.white)
self.titleLabel?.font = UIFont.system(type: .Bold, size: 14)
self.titleLabel?.font = UIFont.system(weight: .bold, size: 14)
self.contentEdgeInsets = UIEdgeInsets.init(top: 6, left: 15, bottom: 6, right: 15)
break
case .buyInStore:
self.backgroundColor = self.baseColor
self.layer.borderWidth = 0
self.setTitleColor(UIColor.white)
self.titleLabel?.font = UIFont.system(type: .Bold, size: 14)
self.titleLabel?.font = UIFont.system(weight: .bold, size: 14)
self.contentEdgeInsets = UIEdgeInsets.init(top: 8, left: 15, bottom: 8, right: 15)
break
case .line:
self.backgroundColor = UIColor.clear
self.layer.borderWidth = 1
self.layer.borderColor = self.baseColor.cgColor
self.titleLabel?.font = UIFont.system(type: .Medium, size: 14)
self.titleLabel?.font = UIFont.system(weight: .medium, size: 14)
self.contentEdgeInsets = UIEdgeInsets.init(top: 6, left: 15, bottom: 6, right: 15)
break
}
@@ -44,7 +44,7 @@ public class SPAppleMusicButton: SPButton {
override func commonInit() {
super.commonInit()
self.layer.cornerRadius = 8
self.titleLabel?.font = UIFont.system(type: .DemiBold, size: 15)
self.titleLabel?.font = UIFont.system(weight: .demiBold, size: 15)
self.contentEdgeInsets = UIEdgeInsets.init(top: 12, left: 27, bottom: 12, right: 27)
self.type = .unselect
}
@@ -64,7 +64,7 @@ public class SPAppleMusicSectionButtonsView: SPView {
func layout(origin: CGPoint, width: CGFloat) {
self.frame.origin = origin
self.set(width: width, height: sectionHeight)
self.frame.set(width: width, height: sectionHeight)
self.layoutSubviews()
}
@@ -72,22 +72,22 @@ public class SPAppleMusicSectionButtonsView: SPView {
super.layoutSubviews()
self.topSeparatorView.frame.origin = .zero
self.topSeparatorView.setWidth(self.frame.width)
self.topSeparatorView.frame.set(width: self.frame.width)
self.bottomSeparatorView.frame.origin.x = 0
self.bottomSeparatorView.frame.bottomYPosition = self.frame.height
self.bottomSeparatorView.setWidth(self.frame.width)
self.bottomSeparatorView.frame.bottomY = self.frame.height
self.bottomSeparatorView.frame.set(width: self.frame.width)
let buttonWidth = (self.frame.width - self.buttonsSpace) / 2
self.leftButton.sizeToFit()
self.leftButton.setWidth(buttonWidth)
self.leftButton.frame.set(width: buttonWidth)
self.leftButton.frame.origin.x = 0
self.leftButton.center.y = self.frame.height / 2
self.rightButton.sizeToFit()
self.rightButton.setWidth(buttonWidth)
self.rightButton.frame.bottomXPosition = self.frame.width
self.rightButton.frame.set(width: buttonWidth)
self.rightButton.frame.bottomX = self.frame.width
self.rightButton.center.y = self.frame.height / 2
}
}
@@ -23,7 +23,28 @@ import UIKit
public class SPButton: UIButton {
var gradientView: SPGradientView? {
override public func imageRect(forContentRect contentRect: CGRect) -> CGRect {
if self.title(for: .normal) != nil {
let inset: CGFloat = 6
let sideSize = self.frame.height - inset * 2
let titleFrame = self.titleRect(forContentRect: contentRect)
return CGRect.init(x: titleFrame.origin.x - sideSize - 6, y: 0, width: sideSize, height: self.frame.height)
} else {
return super.imageRect(forContentRect: contentRect)
}
}
override public var isHighlighted: Bool{
didSet {
if self.isHighlighted {
self.imageView?.alpha = 0.7
} else {
self.imageView?.alpha = 1
}
}
}
public var gradientView: SPGradientView? {
didSet {
self.gradientView?.isUserInteractionEnabled = false
if self.gradientView?.superview == nil {
@@ -34,7 +55,7 @@ public class SPButton: UIButton {
}
}
var round: Bool = false {
public var rounded: Bool = false {
didSet {
self.layoutSubviews()
}
@@ -50,12 +71,14 @@ public class SPButton: UIButton {
self.commonInit()
}
internal func commonInit() {}
internal func commonInit() {
self.adjustsImageWhenHighlighted = false
}
override public func layoutSubviews() {
super.layoutSubviews()
self.gradientView?.setEqualsBoundsFromSuperview()
if self.round {
self.gradientView?.setSuperviewBounds()
if self.rounded {
self.round()
}
}
@@ -69,6 +92,5 @@ public class SPButton: UIButton {
} else {
self.alpha = enable ? 1 : 0.6
}
}
}
@@ -71,8 +71,8 @@ public class SPDotButton: SPButton {
override public func sizeToFit() {
super.sizeToFit()
self.setWidth(self.customSideSize)
self.setHeight(self.customSideSize)
self.frame.set(width: self.customSideSize)
self.frame.set(height: self.customSideSize)
self.layoutSubviews()
}
@@ -87,9 +87,9 @@ public class SPDotButton: SPButton {
var currentXPosition: CGFloat = insest
for dotView in self.dotsView {
dotView.setWidth(sideSize)
dotView.setHeight(sideSize)
dotView.setYCenteringFromSuperview()
dotView.frame.set(width: sideSize)
dotView.frame.set(height: sideSize)
dotView.setYCenter()
dotView.frame.origin.x = currentXPosition
dotView.round()
currentXPosition += (sideSize + space)
@@ -44,7 +44,7 @@ public class SPNativeLargeButton: SPDownloadingButton {
override public func commonInit() {
super.commonInit()
self.titleLabel?.font = UIFont.system(type: UIFont.BoldType.DemiBold, size: 16)
self.titleLabel?.font = UIFont.system(weight: UIFont.FontWeight.demiBold, size: 16)
self.setTitleColor(UIColor.white)
self.backgroundColor = SPNativeColors.blue
self.layer.masksToBounds = true
@@ -58,13 +58,13 @@ public class SPNativeLargeButton: SPDownloadingButton {
let sideSpace: CGFloat = superview.frame.width * 0.112
var width = superview.frame.width - sideSpace * 2
width.setIfMore(when: 335)
self.setWidth(width)
self.frame.set(width: width)
}
}
override public func layoutSubviews() {
super.layoutSubviews()
self.gradientView?.setEqualsBoundsFromSuperview()
self.gradientView?.setSuperviewBounds()
self.gradientView?.layer.cornerRadius = self.layer.cornerRadius
self.gradientView?.gradientLayer.cornerRadius = self.layer.cornerRadius
}
@@ -62,7 +62,7 @@ public class SPPlayCircleButton: UIButton {
override public func layoutSubviews() {
super.layoutSubviews()
self.iconView.setEqualsFrameFromBounds(self, withWidthFactor: 0.45, withHeightFactor: 0.45, withCentering: true)
self.iconView.setBounds(self, withWidthFactor: 0.45, withHeightFactor: 0.45, withCentering: true)
self.round()
}
@@ -81,7 +81,7 @@ public class SPSocialButton: UIButton {
override public func layoutSubviews() {
super.layoutSubviews()
self.iconView.setEqualsFrameFromBounds(self, withWidthFactor: self.widthIconFactor, withHeightFactor: self.heightIconFactor, withCentering: true)
self.iconView.setBounds(self, withWidthFactor: self.widthIconFactor, withHeightFactor: self.heightIconFactor, withCentering: true)
self.round()
}
}
@@ -21,15 +21,16 @@
import UIKit
public class SPSystemIconButton: UIButton {
public class SPSystemIconButton: SPButton {
let iconView = SPSystemIconView.init()
var widthIconFactor: CGFloat = 1
var heightIconFactor: CGFloat = 1
var type: SPSystemIconType {
var icon: SPSystemIcon {
didSet {
self.iconView.type = self.type
self.iconView.icon = self.icon
}
}
@@ -49,17 +50,17 @@ public class SPSystemIconButton: UIButton {
}
}
init() {
self.type = .share
super.init(frame: CGRect.zero)
override init() {
self.icon = .share
super.init()
self.commonInit()
}
init(type: SPSystemIconType) {
self.type = type
super.init(frame: CGRect.zero)
self.iconView.type = self.type
self.type = type
init(type: SPSystemIcon) {
self.icon = type
super.init()
self.iconView.icon = self.icon
self.icon = type
self.commonInit()
}
@@ -67,13 +68,14 @@ public class SPSystemIconButton: UIButton {
fatalError("init(coder:) has not been implemented")
}
fileprivate func commonInit() {
override func commonInit() {
super.commonInit()
self.iconView.isUserInteractionEnabled = false
self.addSubview(self.iconView)
}
override public func layoutSubviews() {
super.layoutSubviews()
self.iconView.setEqualsFrameFromBounds(self, withWidthFactor: self.widthIconFactor, withHeightFactor: self.heightIconFactor, withCentering: true)
self.iconView.setBounds(self, withWidthFactor: self.widthIconFactor, withHeightFactor: self.heightIconFactor, withCentering: true)
}
}
@@ -23,7 +23,7 @@ import UIKit
class SPSystemIconView: UIView {
var type: SPSystemIconType {
var icon: SPSystemIcon {
didSet {
self.setNeedsDisplay()
}
@@ -36,13 +36,13 @@ class SPSystemIconView: UIView {
}
init() {
self.type = .share
self.icon = .share
super.init(frame: CGRect.zero)
self.commonInit()
}
init(type: SPSystemIconType) {
self.type = type
init(type: SPSystemIcon) {
self.icon = type
super.init(frame: CGRect.zero)
self.commonInit()
}
@@ -57,7 +57,7 @@ class SPSystemIconView: UIView {
override func draw(_ rect: CGRect) {
super.draw(rect)
switch type {
switch icon {
case .share:
SPCodeDraw.SystemIconPack.drawShare(frame: rect, resizing: .aspectFit, color: self.color)
break
@@ -125,7 +125,7 @@ public class SPMengTransformCollectionViewCell: SPCollectionViewCell {
self.titleLabel.text = ""
self.titleLabel.setDeepShadowForLetters()
self.titleLabel.translatesAutoresizingMaskIntoConstraints = false
self.titleLabel.font = UIFont.system(type: .DemiBold, size: 32)
self.titleLabel.font = UIFont.system(weight: .demiBold, size: 32)
self.titleLabel.textColor = UIColor.white
self.titleLabel.numberOfLines = 0
contentView.addSubview(self.titleLabel)
@@ -140,7 +140,7 @@ public class SPMengTransformCollectionViewCell: SPCollectionViewCell {
self.subtitleLabel.text = ""
self.subtitleLabel.setDeepShadowForLetters()
self.subtitleLabel.translatesAutoresizingMaskIntoConstraints = false
self.subtitleLabel.font = UIFont.system(type: .Regular, size: 17)
self.subtitleLabel.font = UIFont.system(weight: .regular, size: 17)
self.subtitleLabel.textColor = UIColor.white
self.subtitleLabel.numberOfLines = 0
contentView.addSubview(self.subtitleLabel)
@@ -53,6 +53,10 @@ public class SPCollectionView: UICollectionView {
func height(rows: Int) -> CGFloat {
return self.layout.itemSize.height * CGFloat(rows) + self.layout.minimumLineSpacing * CGFloat(rows - 1)
}
func width(columns: Int) -> CGFloat {
return self.layout.itemSize.width * CGFloat(columns) + self.layout.minimumInteritemSpacing * CGFloat(columns - 1)
}
}
//MARK: - Cache
@@ -23,12 +23,16 @@ import UIKit
public class SPController: SPStatusBarManagerController {
let emptyTitlesView = SPEmptyTitlesView(title: "No Data", subtitle: "No data or information")
let emptyTitlesView = SPEmptyLabelsView(title: "No Data", subtitle: "No data or information")
override public func viewDidLoad() {
super.viewDidLoad()
self.emptyTitlesView.isHidden = true
self.view.addSubview(self.emptyTitlesView)
}
public override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
self.updateLayout(with: self.view.frame.size)
}
@@ -39,12 +43,6 @@ public class SPController: SPStatusBarManagerController {
}, completion: nil)
}
@available(iOS 11.0, *)
override public func viewLayoutMarginsDidChange() {
super.viewLayoutMarginsDidChange()
self.updateLayout(with: self.view.frame.size)
}
func updateLayout(with size: CGSize) {
self.emptyTitlesView.layout(centerY: size.height / 2)
}
@@ -77,8 +77,6 @@ public class SPNativeTableController: SPTableController {
self.activityIndicatorView.stopAnimating()
self.activityIndicatorView.color = SPNativeColors.gray
self.view.addSubview(self.activityIndicatorView)
self.updateLayout(with: self.view.frame.size)
}
override public func numberOfSections(in tableView: UITableView) -> Int {
@@ -31,6 +31,10 @@ public class SPProposeController: SPController {
return 0.5
}
private var gradeFactor: CGFloat {
return 0.6
}
private var space: CGFloat {
return 6
}
@@ -75,8 +79,6 @@ public class SPProposeController: SPController {
if let image = self.data.image {
self.areaView.imageView.setImage(image: image, animatable: false)
}
self.updateLayout(with: self.view.frame.size)
}
override public func viewDidAppear(_ animated: Bool) {
@@ -92,7 +94,7 @@ public class SPProposeController: SPController {
self.areaView.frame.origin.y = self.view.frame.size.height
self.areaView.isHidden = false
SPAnimationSpring.animate(self.animationDuration, animations: {
self.view.backgroundColor = UIColor.black.withAlphaComponent(0.6)
self.view.backgroundColor = UIColor.black.withAlphaComponent(self.gradeFactor)
self.areaView.frame.origin.y = self.view.frame.size.height - self.areaView.frame.height - (self.bottomSafeArea / 2) - self.space
}, spring: 1,
velocity: 1,
@@ -100,7 +102,6 @@ public class SPProposeController: SPController {
}
override public func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
let hide = {
self.view.backgroundColor = UIColor.black.withAlphaComponent(0)
self.areaView.frame.origin.y = self.view.frame.size.height
@@ -128,10 +129,8 @@ public class SPProposeController: SPController {
}
override func updateLayout(with size: CGSize) {
self.areaView.setWidth(size.width - (self.space * 2))
self.areaView.layoutSubviews()
self.areaView.sizeToFit()
self.areaView.frame.origin.x = self.space
super.updateLayout(with: size)
self.areaView.layout(origin: CGPoint.init(x: self.space, y: 0), width: size.width - (self.space * 2))
self.areaView.frame.origin.y = self.view.frame.size.height - self.areaView.frame.height - (self.bottomSafeArea / 2) - self.space
}
@@ -140,6 +139,7 @@ public class SPProposeController: SPController {
let returnAreaViewToPoint = {
SPAnimationSpring.animate(self.animationDuration, animations: {
self.areaView.frame.origin.y = self.view.frame.size.height - self.areaView.frame.height - (self.bottomSafeArea / 2) - self.space
self.view.backgroundColor = UIColor.black.withAlphaComponent(self.gradeFactor)
}, spring: 1,
velocity: 1,
options: .transitionCurlDown,
@@ -156,6 +156,13 @@ public class SPProposeController: SPController {
let translation = sender.translation(in: self.view)
self.areaView.center = CGPoint(x: areaView.center.x + 0, y: areaView.center.y + translation.y / 4)
sender.setTranslation(CGPoint.zero, in: self.view)
let baseY = self.view.frame.size.height - self.areaView.frame.height - (self.bottomSafeArea / 2) - self.space
let dem = -(baseY - self.areaView.frame.origin.y) / 6
var newGrade = self.gradeFactor - (dem / 100)
newGrade.setIfFewer(when: 0.2)
newGrade.setIfMore(when: self.gradeFactor + 0.05)
self.view.backgroundColor = UIColor.black.withAlphaComponent(newGrade)
case .ended:
returnAreaViewToPoint()
default:
@@ -179,10 +186,9 @@ public class SPProposeController: SPController {
let subtitleLabel = UILabel()
let imageView = SPDownloadingImageView()
let button = SPNativeLargeButton()
let closeButton = SPSystemIconButton(type: SPSystemIconType.close)
let closeButton = SPSystemIconButton(type: SPSystemIcon.close)
var imageSideSize: CGFloat = 160
private let space: CGFloat = 36
init() {
@@ -191,18 +197,18 @@ public class SPProposeController: SPController {
self.layer.masksToBounds = true
self.layer.cornerRadius = 34
self.titleLabel.font = UIFont.system(type: .Regular, size: 28)
self.titleLabel.font = UIFont.system(weight: .regular, size: 28)
self.titleLabel.textColor = UIColor.init(hex: "939393")
self.titleLabel.numberOfLines = 1
self.titleLabel.adjustsFontSizeToFitWidth = true
self.titleLabel.minimumScaleFactor = 0.5
self.titleLabel.setCenteringAlignment()
self.titleLabel.setCenterAlignment()
self.addSubview(self.titleLabel)
self.subtitleLabel.font = UIFont.system(type: .Regular, size: 16)
self.subtitleLabel.font = UIFont.system(weight: .regular, size: 16)
self.subtitleLabel.textColor = SPNativeColors.black
self.subtitleLabel.numberOfLines = 0
self.subtitleLabel.setCenteringAlignment()
self.subtitleLabel.setCenterAlignment()
self.addSubview(self.subtitleLabel)
self.imageView.gradeView.backgroundColor = UIColor.white
@@ -210,15 +216,16 @@ public class SPProposeController: SPController {
self.imageView.layer.masksToBounds = true
self.addSubview(self.imageView)
self.button.titleLabel?.font = UIFont.system(type: UIFont.BoldType.Medium, size: 15)
self.button.titleLabel?.font = UIFont.system(weight: UIFont.FontWeight.medium, size: 15)
self.button.setTitleColor(SPNativeColors.black)
self.button.backgroundColor = UIColor.init(hex: "D4D3DB")
self.button.layer.cornerRadius = 13
self.button.backgroundColor = SPNativeColors.lightGray
self.addSubview(self.button)
self.closeButton.widthIconFactor = 0.4
self.closeButton.heightIconFactor = 0.4
self.closeButton.backgroundColor = UIColor.init(hex: "EFEFF4")
self.closeButton.color = UIColor.init(hex: "979797")
self.closeButton.backgroundColor = SPNativeColors.lightGray.withAlphaComponent(0.6)
self.closeButton.color = UIColor.init(hex: "979797")
self.addSubview(self.closeButton)
}
@@ -230,36 +237,40 @@ public class SPProposeController: SPController {
super.layoutSubviews()
self.titleLabel.sizeToFit()
self.titleLabel.frame.origin.y = self.space * 0.8
self.titleLabel.setWidth(self.frame.width - self.space * 3)
self.titleLabel.setXCenteringFromSuperview()
self.titleLabel.frame.origin.y = self.space * 0.9
self.titleLabel.frame.set(width: self.frame.width - self.space * 3)
self.titleLabel.setXCenter()
self.subtitleLabel.sizeToFit()
self.subtitleLabel.frame.origin.y = self.titleLabel.frame.bottomYPosition + 8
self.subtitleLabel.setWidth(self.frame.width - self.space * 2)
self.subtitleLabel.setXCenteringFromSuperview()
self.subtitleLabel.frame.origin.y = self.titleLabel.frame.bottomY + 8
self.subtitleLabel.frame.set(width: self.frame.width - self.space * 2)
self.subtitleLabel.setXCenter()
self.imageView.frame = CGRect.init(
x: 0, y: self.subtitleLabel.frame.bottomYPosition + self.space / 2,
x: 0, y: self.subtitleLabel.frame.bottomY + self.space / 2,
width: self.imageSideSize,
height: self.imageSideSize
)
self.imageView.setXCenteringFromSuperview()
self.imageView.setXCenter()
self.button.sizeToFit()
self.button.setWidth(self.frame.width - self.space * 2)
self.button.frame.origin.y = self.imageView.frame.bottomYPosition + self.space / 2
self.button.setXCenteringFromSuperview()
self.button.frame.set(height: 52)
self.button.frame.set(width: self.frame.width - self.space * 2)
self.button.frame.origin.y = self.imageView.frame.bottomY + self.space / 1.8
self.button.setXCenter()
self.closeButton.frame = CGRect.init(x: 0, y: 0, width: 24, height: 24)
self.closeButton.frame.origin.x = self.frame.width - self.closeButton.frame.width - 20
self.closeButton.frame.origin.y = 20
self.closeButton.round()
self.frame.set(height: self.button.frame.bottomY + self.space)
}
override func sizeToFit() {
super.sizeToFit()
self.setHeight(self.button.frame.bottomYPosition + self.space)
func layout(origin: CGPoint, width: CGFloat) {
self.frame.origin = origin
self.frame.set(width: width)
self.layoutSubviews()
}
}
@@ -31,7 +31,10 @@ public class SPTableController: SPStatusBarManagerTableController {
self.activityIndicatorView.stopAnimating()
self.activityIndicatorView.color = SPNativeColors.gray
self.view.addSubview(self.activityIndicatorView)
}
public override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
self.updateLayout(with: self.view.frame.size)
}
@@ -42,12 +45,6 @@ public class SPTableController: SPStatusBarManagerTableController {
}, completion: nil)
}
@available(iOS 11.0, *)
override public func viewLayoutMarginsDidChange() {
super.viewLayoutMarginsDidChange()
self.updateLayout(with: self.view.frame.size)
}
func updateLayout(with size: CGSize) {
self.activityIndicatorView.center = CGPoint.init(
x: size.width / 2,
@@ -0,0 +1,67 @@
// The MIT License (MIT)
// Copyright © 2017 Ivan Vorobei (hello@ivanvorobei.by)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import UIKit
public class SPCenterLabelsView: SPView {
let titleLabel = SPLabel()
let subtitleLabel = SPLabel()
override func commonInit() {
super.commonInit()
self.titleLabel.font = UIFont.system(weight: .bold, size: 33)
self.titleLabel.textAlignment = .center
self.titleLabel.textColor = UIColor.black
self.titleLabel.numberOfLines = 0
self.addSubview(self.titleLabel)
self.subtitleLabel.font = UIFont.system(weight: .regular, size: 17)
self.subtitleLabel.textAlignment = .center
self.subtitleLabel.textColor = UIColor.black
self.subtitleLabel.numberOfLines = 0
self.addSubview(self.subtitleLabel)
}
func layout(x: CGFloat, y: CGFloat, width: CGFloat) {
self.frame.origin = CGPoint.init(x: x, y: y)
self.frame.set(width: width)
self.layoutSubviews()
}
override public func layoutSubviews() {
super.layoutSubviews()
self.titleLabel.frame.set(width: self.frame.width)
self.titleLabel.sizeToFit()
self.titleLabel.frame.set(width: self.frame.width)
self.titleLabel.frame.origin = CGPoint.zero
self.subtitleLabel.frame.set(width: self.frame.width)
self.subtitleLabel.sizeToFit()
self.subtitleLabel.frame.set(width: self.frame.width)
self.subtitleLabel.frame.origin.x = 0
self.subtitleLabel.frame.origin.y = self.titleLabel.frame.bottomY + 7
self.frame.set(height: self.subtitleLabel.frame.bottomY)
}
}
@@ -21,7 +21,7 @@
import UIKit
class SPEmptyTitlesView: SPView {
class SPEmptyLabelsView: SPView {
let titleLabel = UILabel()
let subtitleLabel = UILabel()
@@ -39,22 +39,22 @@ class SPEmptyTitlesView: SPView {
override func commonInit() {
super.commonInit()
self.titleLabel.font = UIFont.system(type: .Bold, size: 29)
self.titleLabel.font = UIFont.system(weight: .bold, size: 29)
self.titleLabel.textColor = SPNativeColors.gray
self.titleLabel.setCenteringAlignment()
self.titleLabel.setCenterAlignment()
self.titleLabel.numberOfLines = 0
self.addSubview(self.titleLabel)
self.subtitleLabel.font = UIFont.system(type: .Regular, size: 17)
self.subtitleLabel.font = UIFont.system(weight: .regular, size: 17)
self.subtitleLabel.textColor = SPNativeColors.gray
self.subtitleLabel.setCenteringAlignment()
self.subtitleLabel.setCenterAlignment()
self.subtitleLabel.numberOfLines = 0
self.addSubview(self.subtitleLabel)
}
func layout(centerY: CGFloat) {
if let superview = self.superview {
self.setWidth(superview.frame.width * 0.7)
self.frame.set(width: superview.frame.width * 0.7)
self.layoutSubviews()
self.center = CGPoint.init(x: superview.frame.width / 2, y: centerY)
}
@@ -65,12 +65,12 @@ class SPEmptyTitlesView: SPView {
self.titleLabel.frame.origin = .zero
self.titleLabel.sizeToFit()
self.titleLabel.setWidth(self.frame.width)
self.titleLabel.frame.set(width: self.frame.width)
self.subtitleLabel.frame.origin = CGPoint.init(x: 0, y: self.titleLabel.frame.bottomYPosition + 5)
self.subtitleLabel.frame.origin = CGPoint.init(x: 0, y: self.titleLabel.frame.bottomY + 5)
self.subtitleLabel.sizeToFit()
self.subtitleLabel.setWidth(self.frame.width)
self.subtitleLabel.frame.set(width: self.frame.width)
self.setHeight(self.subtitleLabel.frame.bottomYPosition)
self.frame.set(height: self.subtitleLabel.frame.bottomY)
}
}
@@ -30,48 +30,49 @@ public class SPSectionLabelsView: SPView {
override func commonInit() {
super.commonInit()
self.titleLabel.font = UIFont.system(type: .Bold, size: 23)
self.titleLabel.font = UIFont.system(weight: .bold, size: 23)
self.titleLabel.textAlignment = .left
self.titleLabel.textColor = UIColor.black
self.titleLabel.numberOfLines = 0
self.addSubview(self.titleLabel)
self.subtitleLabel.font = UIFont.system(type: .Regular, size: 17)
self.subtitleLabel.font = UIFont.system(weight: .regular, size: 17)
self.subtitleLabel.textAlignment = .left
self.subtitleLabel.textColor = UIColor.black.withAlphaComponent(0.7)
self.subtitleLabel.numberOfLines = 0
self.addSubview(self.subtitleLabel)
self.button.titleLabel?.font = UIFont.system(type: .Regular, size: 17)
self.button.titleLabel?.font = UIFont.system(weight: .regular, size: 17)
self.button.setTitleColor(SPNativeColors.blue, for: UIControl.State.normal)
self.addSubview(self.button)
}
func layout(origin: CGPoint, width: CGFloat) {
self.frame.origin = origin
self.setWidth(width)
self.frame.set(width: width)
self.layoutSubviews()
}
func layout(x: CGFloat, y: CGFloat, width: CGFloat) {
self.layout(origin: CGPoint.init(x: x, y: y), width: width)
}
override public func layoutSubviews() {
super.layoutSubviews()
self.titleLabel.sizeToFit()
self.titleLabel.setWidth(self.frame.width)
self.titleLabel.frame.set(width: self.frame.width)
self.titleLabel.frame.origin = CGPoint.zero
//self.titleLabel.backgroundColor = UIColor.lightGray
self.subtitleLabel.sizeToFit()
self.subtitleLabel.setWidth(self.frame.width)
self.subtitleLabel.frame.set(width: self.frame.width)
self.subtitleLabel.frame.origin.x = 0
self.subtitleLabel.frame.origin.y = self.titleLabel.frame.bottomYPosition + 3
//self.subtitleLabel.backgroundColor = UIColor.darkGray
self.subtitleLabel.frame.origin.y = self.titleLabel.frame.bottomY + 3
self.button.sizeToFit()
self.button.frame.bottomXPosition = self.frame.width
self.button.frame.bottomX = self.frame.width
self.button.center.y = self.titleLabel.center.y
//self.button.backgroundColor = UIColor.darkGray
self.setHeight(self.subtitleLabel.frame.bottomYPosition)
self.frame.set(height: self.subtitleLabel.frame.bottomY)
}
}
@@ -33,7 +33,7 @@ public class SPDownloadingImageView: SPImageView {
self.addSubview(self.gradeView)
self.gradeView.backgroundColor = UIColor.init(hex: "F0F1F6")
self.activityIndiactorView.color = UIColor.darkGray
self.addSubview(self.activityIndiactorView)
//self.addSubview(self.activityIndiactorView)
self.activityIndiactorView.startAnimating()
}
@@ -70,7 +70,7 @@ public class SPDownloadingImageView: SPImageView {
override public func layoutSubviews() {
super.layoutSubviews()
self.gradeView.setEqualsBoundsFromSuperview()
self.gradeView.setSuperviewBounds()
self.activityIndiactorView.center = CGPoint.init(x: self.bounds.midX, y: self.bounds.midY)
}
}
@@ -23,7 +23,7 @@ import UIKit
public class SPFakeBarView: UIView {
public var style: SPNavigationTitleStyle = . small {
public var style: SPNavigationTitleStyle = .small {
didSet {
self.updateStyle()
}
@@ -56,13 +56,13 @@ public class SPFakeBarView: UIView {
public var closeButtonPossition: CloseButtonPosition = .none {
didSet {
self.leftButton.titleLabel?.font = UIFont.system(type: .Regular, size: 17)
self.rightButton.titleLabel?.font = UIFont.system(type: .Regular, size: 17)
self.leftButton.titleLabel?.font = UIFont.system(weight: .regular, size: 17)
self.rightButton.titleLabel?.font = UIFont.system(weight: .regular, size: 17)
switch self.closeButtonPossition {
case .left:
self.leftButton.titleLabel?.font = UIFont.system(type: .DemiBold, size: 17)
self.leftButton.titleLabel?.font = UIFont.system(weight: .demiBold, size: 17)
case .right:
self.rightButton.titleLabel?.font = UIFont.system(type: .DemiBold, size: 17)
self.rightButton.titleLabel?.font = UIFont.system(weight: .demiBold, size: 17)
case .none:
break
}
@@ -121,7 +121,7 @@ public class SPFakeBarView: UIView {
self.addSubview(self.subtitleLabel)
self.subtitleLabel.textColor = UIColor.init(hex: "8E8E92")
self.subtitleLabel.font = UIFont.system(type: .DemiBold, size: 13)
self.subtitleLabel.font = UIFont.system(weight: .demiBold, size: 13)
self.subtitleLabel.translatesAutoresizingMaskIntoConstraints = false
self.subtitleLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 16).isActive = true
self.subtitleLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -16).isActive = true
@@ -129,7 +129,7 @@ public class SPFakeBarView: UIView {
self.leftButton.setTitleColor(self.elementsColor)
self.leftButton.titleLabel?.textAlignment = .left
self.leftButton.titleLabel?.font = UIFont.system(type: .DemiBold, size: 16)
self.leftButton.titleLabel?.font = UIFont.system(weight: .demiBold, size: 16)
self.leftButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 17, bottom: 0, right: 0)
self.addSubview(self.leftButton)
self.leftButton.translatesAutoresizingMaskIntoConstraints = false
@@ -138,7 +138,7 @@ public class SPFakeBarView: UIView {
self.rightButton.setTitleColor(self.elementsColor)
self.rightButton.titleLabel?.textAlignment = .right
self.rightButton.titleLabel?.font = UIFont.system(type: .DemiBold, size: 17)
self.rightButton.titleLabel?.font = UIFont.system(weight: .demiBold, size: 17)
self.rightButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 16)
self.addSubview(self.rightButton)
self.rightButton.translatesAutoresizingMaskIntoConstraints = false
@@ -185,14 +185,14 @@ public class SPFakeBarView: UIView {
self.titleBottomConstraint?.constant = -12
}
self.addStatusBarHeight = true
self.titleLabel.font = UIFont.system(type: .DemiBold, size: 17)
self.titleLabel.setCenteringAlignment()
self.titleLabel.font = UIFont.system(weight: .demiBold, size: 17)
self.titleLabel.setCenterAlignment()
case .stork:
self.height = 66
self.titleBottomConstraint?.constant = -12
self.addStatusBarHeight = false
self.titleLabel.font = UIFont.system(type: .DemiBold, size: 17)
self.titleLabel.setCenteringAlignment()
self.titleLabel.font = UIFont.system(weight: .demiBold, size: 17)
self.titleLabel.setCenterAlignment()
case .large:
if UIViewController.statusBarHeight == 44 {
self.height = 140 - 44
@@ -202,7 +202,7 @@ public class SPFakeBarView: UIView {
self.titleBottomConstraint?.constant = -4
}
self.addStatusBarHeight = true
self.titleLabel.font = UIFont.system(type: .Bold, size: 34)
self.titleLabel.font = UIFont.system(weight: .bold, size: 34)
self.titleLabel.textAlignment = .left
break
}
@@ -36,8 +36,7 @@ public class SPFooterActionsView: SPView {
func addButton(title: String, titleColor: UIColor, target: @escaping ()->()) {
let button = SPFooterActionButton()
button.setTitle(title)
button.setTitleColor(titleColor)
button.setTitle(title, color: titleColor)
button.target { target() }
self.buttons.append(button)
self.addSubview(button)
@@ -56,7 +55,7 @@ public class SPFooterActionsView: SPView {
func layout(origin: CGPoint, width: CGFloat) {
self.frame.origin = origin
self.setWidth(width)
self.frame.set(width: width)
self.layoutSubviews()
}
@@ -66,7 +65,7 @@ public class SPFooterActionsView: SPView {
self.sectionLabels.layout(origin: CGPoint.zero, width: self.frame.width)
let buttonHeight: CGFloat = 50
var yPositionButton: CGFloat = self.sectionLabels.frame.bottomYPosition + 12
var yPositionButton: CGFloat = self.sectionLabels.frame.bottomY + 12
if !self.buttons.isEmpty {
for i in 0...(buttons.count - 1) {
@@ -75,14 +74,14 @@ public class SPFooterActionsView: SPView {
separator.frame.origin.x = 0
separator.frame.origin.y = yPositionButton
separator.setWidth(self.frame.width)
separator.frame.set(width: self.frame.width)
button.frame = CGRect.init(x: 0, y: yPositionButton, width: self.frame.width, height: buttonHeight)
yPositionButton += buttonHeight
}
self.setHeight(yPositionButton)
self.frame.set(height: yPositionButton)
}
}
}
@@ -104,7 +103,7 @@ class SPFooterActionButton: SPButton {
override func commonInit() {
super.commonInit()
self.setTitleColor(SPNativeColors.blue)
self.titleLabel?.font = UIFont.system(type: .Regular, size: 21)
self.titleLabel?.font = UIFont.system(weight: .regular, size: 21)
self.contentHorizontalAlignment = .left
}
@@ -113,6 +112,6 @@ class SPFooterActionButton: SPButton {
let sideSize: CGFloat = self.frame.height * 0.36
self.rightIconView?.frame = CGRect.init(x: 0, y: 0, width: sideSize, height: sideSize)
self.rightIconView?.center.y = self.frame.height / 2
self.rightIconView?.frame.bottomXPosition = self.frame.width - sideSize / 3
self.rightIconView?.frame.bottomX = self.frame.width - sideSize / 3
}
}
@@ -47,7 +47,6 @@ public class SPScrollView: UIScrollView {
&& !(view is UISwitch) {
return true
}
return super.touchesShouldCancel(in: view)
}
}
@@ -31,16 +31,17 @@ class SPSeparatorView: SPView {
super.commonInit()
self.backgroundColor = UIColor.init(hex: "515B66").withAlphaComponent(0.25)
self.round = true
self.setHeight(self.height)
self.frame.set(height: self.height)
}
func layout(origin: CGPoint, width: CGFloat) {
self.frame.origin = CGPoint.init(x: floor(origin.x), y: floor(origin.y))
self.set(width: floor(width), height: self.height)
self.frame.set(width: floor(width))
self.frame.set(height: self.height)
}
override func layoutSubviews() {
super.layoutSubviews()
self.setHeight(self.height)
self.frame.set(height: self.height)
}
}
@@ -52,6 +52,6 @@ class SPVideoPlayerView: UIView {
override func layoutSubviews() {
super.layoutSubviews()
self.playerController.view.setEqualsBoundsFromSuperview()
self.playerController.view.setSuperviewBounds()
}
}
@@ -46,7 +46,7 @@ public class SPFormButtonTableViewCell: UITableViewCell {
self.button.setTitle("Button", for: .normal)
self.button.backgroundColor = UIColor.clear
self.button.setTitleColor(SPNativeColors.blue)
self.button.titleLabel?.font = UIFont.system(type: .Medium, size: 17)
self.button.titleLabel?.font = UIFont.system(weight: .medium, size: 17)
self.selectionStyle = .none
self.contentView.addSubview(self.button)
}
@@ -60,7 +60,7 @@ public class SPFormButtonTableViewCell: UITableViewCell {
override public func layoutSubviews() {
super.layoutSubviews()
self.button.setEqualsBoundsFromSuperview()
self.button.setSuperviewBounds()
switch self.separatorInsetStyle {
case .all:
@@ -30,10 +30,10 @@ public class SPFormFeaturedTitleTableViewCell: UITableViewCell {
didSet {
switch type {
case .large:
self.titleLabel.font = UIFont.system(type: .Bold, size: 22)
self.titleLabel.font = UIFont.system(weight: .bold, size: 22)
self.titleLabel.textColor = UIColor.black
case .smallColorful:
self.titleLabel.font = UIFont.system(type: .DemiBold, size: 11)
self.titleLabel.font = UIFont.system(weight: .demiBold, size: 11)
self.titleLabel.textColor = SPNativeColors.blue
self.titleLabel.text = self.titleLabel.text?.uppercased()
}
@@ -69,7 +69,7 @@ public class SPFormFeaturedTitleTableViewCell: UITableViewCell {
contentView.addSubview(self.titleLabel)
self.titleLabel.numberOfLines = 0
self.titleLabel.text = "Title"
self.titleLabel.font = UIFont.system(type: .Bold, size: 21)
self.titleLabel.font = UIFont.system(weight: .bold, size: 21)
self.titleLabel.translatesAutoresizingMaskIntoConstraints = false
self.titleLabel.setLettersSpacing(-0.24)
@@ -83,7 +83,7 @@ public class SPFormFeaturedTitleTableViewCell: UITableViewCell {
self.withButton = false
self.button.setTitle("Button Title", for: UIControl.State.normal)
self.button.setTitleColor(SPNativeColors.blue)
self.button.titleLabel?.font = UIFont.system(type: .Medium, size: 17)
self.button.titleLabel?.font = UIFont.system(weight: .medium, size: 17)
self.button.translatesAutoresizingMaskIntoConstraints = false
self.button.titleLabel?.textAlignment = .right
contentView.addSubview(self.button)
@@ -58,13 +58,13 @@ public class SPFormLabelTableViewCell: SPTableViewCell {
self.label.textAlignment = .left
self.label.text = "Title"
self.label.numberOfLines = 1
self.label.font = UIFont.system(type: .Regular, size: 17)
self.label.font = UIFont.system(weight: .regular, size: 17)
self.contentView.addSubview(self.label)
self.descriptionLabel.textAlignment = .right
self.descriptionLabel.text = "Description"
self.descriptionLabel.numberOfLines = 1
self.descriptionLabel.font = UIFont.system(type: .Regular, size: 17)
self.descriptionLabel.font = UIFont.system(weight: .regular, size: 17)
self.descriptionLabel.textColor = SPNativeColors.gray
self.contentView.addSubview(self.descriptionLabel)
@@ -87,7 +87,7 @@ public class SPFormLabelTableViewCell: SPTableViewCell {
override public func layoutSubviews() {
super.layoutSubviews()
let xPosition: CGFloat = (self.imageView?.frame.bottomXPosition ?? 0) + self.layoutMargins.left
let xPosition: CGFloat = (self.imageView?.frame.bottomX ?? 0) + self.layoutMargins.left
var labelWidth: CGFloat = self.contentView.frame.width * 0.45
if let width = self.fixWidthLabel {
@@ -101,9 +101,9 @@ public class SPFormLabelTableViewCell: SPTableViewCell {
let space: CGFloat = 15
self.descriptionLabel.frame = CGRect.init(
x: self.label.frame.bottomXPosition + space,
x: self.label.frame.bottomX + space,
y: 0,
width: self.contentView.frame.width - self.label.frame.bottomXPosition -
width: self.contentView.frame.width - self.label.frame.bottomX -
self.contentView.layoutMargins.right - space,
height: self.contentView.frame.height)
@@ -119,7 +119,7 @@ public class SPFormLabelTableViewCell: SPTableViewCell {
self.separatorInset.left = 0
case .beforeImage:
if let imageView = self.imageView {
self.separatorInset.left = imageView.frame.bottomYPosition + self.layoutMargins.left
self.separatorInset.left = imageView.frame.bottomY + self.layoutMargins.left
} else {
self.separatorInset.left = 0
}
@@ -60,10 +60,10 @@ public class SPFormTextFiledTableViewCell: UITableViewCell {
self.backgroundColor = UIColor.white
self.label.text = "Label"
self.label.font = UIFont.system(type: .Regular, size: 17)
self.label.font = UIFont.system(weight: .regular, size: 17)
self.contentView.addSubview(self.label)
self.textField.font = UIFont.system(type: .Regular, size: 17)
self.textField.font = UIFont.system(weight: .regular, size: 17)
self.textField.placeholder = "Placeholder"
self.contentView.addSubview(self.textField)
@@ -79,7 +79,7 @@ public class SPFormTextFiledTableViewCell: UITableViewCell {
}
self.label.frame = CGRect.init(x: self.layoutMargins.left, y: 0, width: labelWidth, height: self.contentView.frame.height)
let space: CGFloat = 15
self.textField.frame = CGRect.init(x: self.label.frame.bottomXPosition + space, y: 0, width: self.contentView.frame.width - self.label.frame.bottomXPosition - self.layoutMargins.right - space, height: self.contentView.frame.height)
self.textField.frame = CGRect.init(x: self.label.frame.bottomX + space, y: 0, width: self.contentView.frame.width - self.label.frame.bottomX - self.layoutMargins.right - space, height: self.contentView.frame.height)
switch self.separatorInsetStyle {
case .all:
@@ -61,7 +61,7 @@ public class SPFormTextInputTableViewCell: SPTableViewCell {
self.backgroundColor = UIColor.white
self.textInputView.textAlignment = .left
self.textInputView.text = ""
self.textInputView.font = UIFont.system(type: .Regular, size: 17)
self.textInputView.font = UIFont.system(weight: .regular, size: 17)
self.textInputView.translatesAutoresizingMaskIntoConstraints = false
self.textInputView.showsVerticalScrollIndicator = false
self.contentView.addSubview(self.textInputView)
@@ -90,7 +90,7 @@ public class SPFormTextInputTableViewCell: SPTableViewCell {
override public func layoutSubviews() {
super.layoutSubviews()
let xPosition: CGFloat = (self.imageView?.frame.bottomXPosition ?? 0) + self.layoutMargins.left
let xPosition: CGFloat = (self.imageView?.frame.bottomX ?? 0) + self.layoutMargins.left
self.textInputView.frame = CGRect.init(
x: xPosition, y: 0,
@@ -103,7 +103,7 @@ public class SPFormTextInputTableViewCell: SPTableViewCell {
self.separatorInset.left = 0
case .beforeImage:
if let imageView = self.imageView {
self.separatorInset.left = imageView.frame.bottomYPosition + self.layoutMargins.left
self.separatorInset.left = imageView.frame.bottomY + self.layoutMargins.left
} else {
self.separatorInset.left = 0
}
@@ -214,7 +214,7 @@ public class SPBaseContentTableViewCell: SPTableViewCell {
//titleLabel
self.titleLabel.numberOfLines = 0
self.titleLabel.font = UIFont.system(type: UIFont.BoldType.Medium, size: 17)
self.titleLabel.font = UIFont.system(weight: UIFont.FontWeight.medium, size: 17)
self.titleLabel.textAlignment = .left
self.titleLabel.textColor = UIColor.black
self.contentView.addSubview(self.titleLabel)
@@ -234,7 +234,7 @@ public class SPBaseContentTableViewCell: SPTableViewCell {
//subtitleLabel
self.subtitleLabel.numberOfLines = 0
self.subtitleLabel.font = UIFont.system(type: UIFont.BoldType.Regular, size: 15)
self.subtitleLabel.font = UIFont.system(weight: UIFont.FontWeight.regular, size: 15)
self.subtitleLabel.textAlignment = .left
self.subtitleLabel.textColor = UIColor.black
self.contentView.addSubview(self.subtitleLabel)
@@ -248,7 +248,7 @@ public class SPBaseContentTableViewCell: SPTableViewCell {
//descriptionLabel
self.descriptionLabel.numberOfLines = 0
self.descriptionLabel.font = UIFont.system(type: UIFont.BoldType.Regular, size: 15)
self.descriptionLabel.font = UIFont.system(weight: UIFont.FontWeight.regular, size: 15)
self.descriptionLabel.textAlignment = .left
self.descriptionLabel.textColor = SPNativeColors.gray
self.contentView.addSubview(self.descriptionLabel)
@@ -295,15 +295,15 @@ public class SPBaseContentTableViewCell: SPTableViewCell {
self.iconImageView.setNative()
self.titleLabel.text = "Title"
self.titleLabel.font = UIFont.system(type: UIFont.BoldType.Medium, size: 17)
self.titleLabel.font = UIFont.system(weight: UIFont.FontWeight.medium, size: 17)
self.titleLabel.textAlignment = .left
self.titleLabel.textColor = UIColor.black
self.subtitleLabel.text = "Subtitle"
self.subtitleLabel.font = UIFont.system(type: UIFont.BoldType.Regular, size: 15)
self.subtitleLabel.font = UIFont.system(weight: UIFont.FontWeight.regular, size: 15)
self.subtitleLabel.textAlignment = .left
self.subtitleLabel.textColor = UIColor.black
self.descriptionLabel.text = "Description"
self.descriptionLabel.font = UIFont.system(type: UIFont.BoldType.Regular, size: 15)
self.descriptionLabel.font = UIFont.system(weight: UIFont.FontWeight.regular, size: 15)
self.descriptionLabel.textAlignment = .left
self.descriptionLabel.textColor = SPNativeColors.gray
self.button.setTitle("Button")
@@ -63,7 +63,7 @@ public class SPImageTableViewCell: SPTableViewCell {
let marginGuide = contentView.layoutMarginsGuide
self.titleLabel.numberOfLines = 0
self.titleLabel.font = UIFont.system(type: UIFont.BoldType.Medium, size: 21)
self.titleLabel.font = UIFont.system(weight: UIFont.FontWeight.medium, size: 21)
self.titleLabel.textAlignment = .left
self.titleLabel.textColor = UIColor.black
self.contentView.addSubview(self.titleLabel)
@@ -77,7 +77,7 @@ public class SPImageTableViewCell: SPTableViewCell {
self.titleLabelTopConstraint.isActive = true
self.subtitleLabel.numberOfLines = 3
self.subtitleLabel.font = UIFont.system(type: UIFont.BoldType.Regular, size: 15)
self.subtitleLabel.font = UIFont.system(weight: UIFont.FontWeight.regular, size: 15)
self.subtitleLabel.textAlignment = .left
self.subtitleLabel.textColor = SPNativeColors.gray
self.contentView.addSubview(self.subtitleLabel)
@@ -115,7 +115,7 @@ public class SPImageTableViewCell: SPTableViewCell {
override public func layoutSubviews() {
super.layoutSubviews()
self.accessoryView?.center.y = self.titleLabel.frame.bottomYPosition + self.subtitleLabel.frame.height / 2
self.accessoryView?.center.y = self.titleLabel.frame.bottomY + self.subtitleLabel.frame.height / 2
if self.accessoryView?.frame.origin.y ?? 0 < 5 {
self.accessoryView?.center.y = self.frame.height / 2
}
@@ -49,10 +49,10 @@ public class SPPromoTableViewCell: SPBaseContentTableViewCell {
self.spaceAfterDescribtion = 16
self.bottomSpace = 22
self.titleLabel.font = UIFont.system(type: .DemiBold, size: 16)
self.titleLabel.setCenteringAlignment()
self.descriptionLabel.font = UIFont.system(type: .Regular, size: 13)
self.descriptionLabel.setCenteringAlignment()
self.titleLabel.font = UIFont.system(weight: .demiBold, size: 16)
self.titleLabel.setCenterAlignment()
self.descriptionLabel.font = UIFont.system(weight: .regular, size: 13)
self.descriptionLabel.setCenterAlignment()
self.subtitleLabel.textColor = UIColor.lightGray
self.button.style = .main
}
@@ -35,7 +35,7 @@ public class SPProposeTableViewCell: UITableViewCell {
self.addSubview(self.button)
self.button.setTitle("Action", for: .normal)
self.button.titleLabel?.font = UIFont.system(type: .DemiBold, size: 14)
self.button.titleLabel?.font = UIFont.system(weight: .demiBold, size: 14)
self.button.titleLabel?.numberOfLines = 0
self.button.secondColor = SPNativeColors.blue
self.button.baseColor = UIColor.white
@@ -48,9 +48,9 @@ public class SPProposeTableViewCell: UITableViewCell {
self.addSubview(self.titleLabel)
self.titleLabel.numberOfLines = 0
self.titleLabel.setCenteringAlignment()
self.titleLabel.setCenterAlignment()
self.titleLabel.textAlignment = .left
self.titleLabel.font = UIFont.system(type: .Regular, size: 16)
self.titleLabel.font = UIFont.system(weight: .regular, size: 16)
self.titleLabel.translatesAutoresizingMaskIntoConstraints = false
self.titleLabel.leadingAnchor.constraint(equalTo: marginGuide.leadingAnchor).isActive = true
self.titleLabel.topAnchor.constraint(equalTo: marginGuide.topAnchor, constant: 0).isActive = true
@@ -21,9 +21,7 @@
import UIKit
public struct SPVibration { private init() {} }
extension SPVibration {
public struct SPVibration {
public static func impact(_ style: Style) {
@@ -57,4 +55,6 @@ extension SPVibration {
case success
case warning
}
private init() {}
}
@@ -18,8 +18,6 @@ class ModalTableViewController: UIViewController {
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
self.tableView.contentInset.top = self.navBar.height
self.tableView.scrollIndicatorInsets.top = self.navBar.height
self.tableView.contentInset.bottom = self.safeArea.bottom
self.tableView.scrollIndicatorInsets.bottom = self.safeArea.bottom
self.view.addSubview(self.tableView)
self.navBar.titleLabel.text = "Table"
@@ -30,21 +28,13 @@ class ModalTableViewController: UIViewController {
self.updateLayout(with: self.view.frame.size)
}
override public func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
coordinator.animate(alongsideTransition: { (contex) in
self.updateLayout(with: size)
}, completion: nil)
}
@available(iOS 11.0, *)
override public func viewLayoutMarginsDidChange() {
super.viewLayoutMarginsDidChange()
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
self.updateLayout(with: self.view.frame.size)
}
func updateLayout(with size: CGSize) {
self.tableView.frame = CGRect.init(origin: CGPoint.zero, size: size)
self.tableView.frame = CGRect.init(x: 0, y: 0, width: size.width, height: size.height)
}
@objc func dismissAction() {
+2 -9
View File
@@ -63,10 +63,6 @@ controller.transitioningDelegate = SPStorkTransitioningDelegate()
You will get an error about weak property.
### Need help
Please, see [this issue](https://github.com/IvanVorobei/SPStorkController/issues/30). Bug with work table. Need help for fix it and update project.
### Video Tutorial
You can see how to use `SPStorkController` and how to customize it [in this video](https://youtu.be/wOTNGswT2-0). For English speakers Ive added subtitles, dont forget to turn them on:
@@ -182,17 +178,14 @@ func scrollViewDidScroll(_ scrollView: UIScrollView) {
Working with a collections classes is not difficult. In the `Example` folder you can find an implementation. However, I will give a couple of tips for making the table look better.
Firstly, if you use `SPFakeBarView`, don't forget to set top insets for content & scroll indicator. Also, I recommend setting bottom insets:
Firstly, if you use `SPFakeBarView`, don't forget to set top insets for content & scroll indicator. Also, I recommend setting bottom insets (it optional):
```swift
tableView.contentInset.top = self.navBar.height
tableView.scrollIndicatorInsets.top = self.navBar.height
tableView.contentInset.bottom = self.safeAreaInsets.bottom
tableView.scrollIndicatorInsets.bottom = self.safeAreaInsets.bottom
```
Please, also use `SPStorkController.scrollViewDidScroll()` function in delegate for more interactiveness with your collection or table view
Please, also use `SPStorkController.scrollViewDidScroll` function in scroll delegate for more interactiveness with your collection or table view.
### Modal presentation of different controller
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SPStorkController"
s.version = "1.4.5"
s.version = "1.4.8"
s.summary = "Modal controller as mail or Apple music application"
s.homepage = "https://github.com/IvanVorobei/SPStorkController"
s.source = { :git => "https://github.com/IvanVorobei/SPStorkController.git", :tag => s.version }
+14
View File
@@ -28,14 +28,28 @@ public struct SPStorkController {
if let presentationController = controller.presentationController as? SPStorkPresentationController {
let translation = -(scrollView.contentOffset.y + scrollView.contentInset.top)
if translation >= 0 {
if controller.isBeingPresented { return }
scrollView.subviews.forEach {
$0.transform = CGAffineTransform(translationX: 0, y: -translation)
}
presentationController.setIndicator(style: scrollView.isDragging ? .line : .arrow)
if translation >= presentationController.translateForDismiss * 0.65 {
if !scrollView.isDragging {
presentationController.presentedViewController.dismiss(animated: true, completion: nil)
return
}
}
if presentationController.pan?.state != UIGestureRecognizer.State.changed {
presentationController.scrollViewDidScroll(translation)
}
} else {
presentationController.setIndicator(style: .arrow)
presentationController.scrollViewDidScroll(0)
}
}
View File
View File
+9 -3
View File
@@ -135,8 +135,9 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
containerView.insertSubview(snapshotView, aboveSubview: self.backgroundView)
snapshotView.frame = initialFrame
snapshotView.transform = transformForSnapshotView
snapshotView.alpha = self.alpha
snapshotView.alpha = 1 - self.alpha
snapshotView.layer.cornerRadius = self.cornerRadius
snapshotView.contentMode = .top
snapshotView.layer.masksToBounds = true
rootSnapshotView = snapshotView
@@ -227,6 +228,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
containerView.insertSubview(snapshotView, aboveSubview: backgroundView)
snapshotView.frame = initialFrame
snapshotView.transform = initialTransform
snapshotView.contentMode = .top
rootSnapshotView = snapshotView
snapshotView.layer.cornerRadius = self.cornerRadius
snapshotView.layer.masksToBounds = true
@@ -234,7 +236,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
let snapshotRoundedView = UIView()
snapshotRoundedView.layer.cornerRadius = self.cornerRadius
snapshotRoundedView.layer.masksToBounds = true
snapshotRoundedView.backgroundColor = UIColor.black.withAlphaComponent(1 - self.alpha)
snapshotRoundedView.backgroundColor = UIColor.black.withAlphaComponent(self.alpha)
containerView.insertSubview(snapshotRoundedView, aboveSubview: snapshotView)
snapshotRoundedView.frame = initialFrame
snapshotRoundedView.transform = initialTransform
@@ -292,7 +294,7 @@ extension SPStorkPresentationController {
self.workGester = false
let translation = gestureRecognizer.translation(in: presentedView).y
if translation >= self.translateForDismiss {
presentedViewController.dismiss(animated: true, completion: nil)
self.presentedViewController.dismiss(animated: true, completion: nil)
} else {
self.indicatorView.style = .arrow
UIView.animate(
@@ -323,6 +325,10 @@ extension SPStorkPresentationController {
self.updateSnapshot()
}
func setIndicator(style: SPStorkIndicatorView.Style) {
self.indicatorView.style = style
}
private func updatePresentedViewForTranslation(inVerticalDirection translation: CGFloat) {
if self.startDismissing { return }
+2 -9
View File
@@ -25,21 +25,14 @@ final class SPStorkPresentingAnimationController: NSObject, UIViewControllerAnim
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard let presentedViewController = transitionContext.viewController(forKey: .to) else {
return
}
guard let presentedViewController = transitionContext.viewController(forKey: .to) else { return }
let containerView = transitionContext.containerView
containerView.addSubview(presentedViewController.view)
//presentedViewController.view.frame = CGRect(x: 0, y: containerView.bounds.height, width: containerView.bounds.width, height: containerView.bounds.height)
let finalFrameForPresentedView = transitionContext.finalFrame(for: presentedViewController)
// NEW FRAMING: Testing now. Maybe correct. If remove it lines, init frame of controller will be equal container (not stork)
presentedViewController.view.frame = finalFrameForPresentedView
presentedViewController.view.frame.origin.y = containerView.bounds.height
// END NEW.
UIView.animate(
withDuration: transitionDuration(using: transitionContext),
View File
View File