* files reorganization (#432) * fix podspec * only include swift files * Fix broken readme paths (#433) * update links * fix french link * split skeleton debug to public and internal methods (#434) * Add build phase to execute SwiftLint (#435) * update tvOS tests * Refactor Extensions folder (#436) * Reorganize SkeletonAppearance (#437) * reorganize helpers and builders folders (#438) * Refactor flow and multilines (#439) * Reorganize collections folder (#440) * reorganize collections folder * update podspec * Refactor SkeletonView facade (#441) * reorganize collections folder * update podspec * refactor skeletonview facade * fix conflict * update iOS example * fix github workflows * update tvOS example project build settings
121 lines
2.6 KiB
Swift
121 lines
2.6 KiB
Swift
//
|
|
// Copyright SkeletonView. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// PrepareViewForSkeleton.swift
|
|
//
|
|
// Created by Juanpe Catalán on 04/11/2017.
|
|
|
|
import UIKit
|
|
|
|
extension UIView {
|
|
|
|
@objc func prepareViewForSkeleton() {
|
|
if isUserInteractionDisabledWhenSkeletonIsActive {
|
|
isUserInteractionEnabled = false
|
|
}
|
|
|
|
startTransition { [weak self] in
|
|
self?.backgroundColor = .clear
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension UILabel {
|
|
|
|
override func prepareViewForSkeleton() {
|
|
backgroundColor = .clear
|
|
|
|
if isUserInteractionDisabledWhenSkeletonIsActive {
|
|
isUserInteractionEnabled = false
|
|
}
|
|
|
|
resignFirstResponder()
|
|
startTransition { [weak self] in
|
|
self?.updateHeightConstraintsIfNeeded()
|
|
self?.textColor = .clear
|
|
}
|
|
}
|
|
}
|
|
|
|
extension UITextView {
|
|
|
|
override func prepareViewForSkeleton() {
|
|
backgroundColor = .clear
|
|
|
|
if isUserInteractionDisabledWhenSkeletonIsActive {
|
|
isUserInteractionEnabled = false
|
|
}
|
|
|
|
resignFirstResponder()
|
|
startTransition { [weak self] in
|
|
self?.textColor = .clear
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension UITextField {
|
|
|
|
override func prepareViewForSkeleton() {
|
|
backgroundColor = .clear
|
|
resignFirstResponder()
|
|
|
|
startTransition { [weak self] in
|
|
self?.textColor = .clear
|
|
self?.placeholder = nil
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension UIImageView {
|
|
|
|
override func prepareViewForSkeleton() {
|
|
backgroundColor = .clear
|
|
|
|
if isUserInteractionDisabledWhenSkeletonIsActive {
|
|
isUserInteractionEnabled = false
|
|
}
|
|
|
|
startTransition { [weak self] in
|
|
self?.image = nil
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension UIButton {
|
|
|
|
override func prepareViewForSkeleton() {
|
|
backgroundColor = .clear
|
|
|
|
if isUserInteractionDisabledWhenSkeletonIsActive {
|
|
isUserInteractionEnabled = false
|
|
}
|
|
|
|
startTransition { [weak self] in
|
|
self?.setTitle(nil, for: .normal)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension UITableViewHeaderFooterView {
|
|
|
|
override func prepareViewForSkeleton() {
|
|
backgroundView?.backgroundColor = .clear
|
|
|
|
if isUserInteractionDisabledWhenSkeletonIsActive {
|
|
isUserInteractionEnabled = false
|
|
}
|
|
}
|
|
|
|
}
|