Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ff1a7e299b | |||
| 4994907234 | |||
| 17fb1b9950 |
@@ -63,9 +63,9 @@ Enjoy it! 🙂
|
||||
|
||||
## 🎬 Guides
|
||||
|
||||
| [](https://youtu.be/75kgOhWsPNA)|[](https://youtu.be/MVCiM_VdxVA)|[](https://youtu.be/Qq3Evspeea8)|[](https://youtu.be/ZOoPtBwDRT0)|[](https://www.youtube.com/watch?v=Zx1Pg1gPfxA)
|
||||
|:---: | :---: |:---: | :---: | :---:
|
||||
|[**SkeletonView Guides - Getting started**](https://youtu.be/75kgOhWsPNA)|[**How to Create Loading View with Skeleton View in Swift 5.2**](https://youtu.be/MVCiM_VdxVA) by iKh4ever Studio|[**Create Skeleton Loading View in App (Swift 5) - Xcode 11, 2020**](https://youtu.be/Qq3Evspeea8) by iOS Academy| [**Add An Elegant Loading Animation in Swift***](https://youtu.be/ZOoPtBwDRT0) by Gary Tokman| [**Cómo crear una ANIMACIÓN de CARGA de DATOS en iOS**](https://www.youtube.com/watch?v=Zx1Pg1gPfxA) by MoureDev
|
||||
| [](https://youtu.be/75kgOhWsPNA)|[](https://youtu.be/MVCiM_VdxVA)|[](https://youtu.be/Qq3Evspeea8)|[](https://www.youtube.com/watch?v=Zx1Pg1gPfxA)
|
||||
|:---: | :---: | :---: | :---:
|
||||
|[**SkeletonView Guides - Getting started**](https://youtu.be/75kgOhWsPNA)|[**How to Create Loading View with Skeleton View in Swift 5.2**](https://youtu.be/MVCiM_VdxVA) by iKh4ever Studio|[**Create Skeleton Loading View in App (Swift 5) - Xcode 11, 2020**](https://youtu.be/Qq3Evspeea8) by iOS Academy| [**Cómo crear una ANIMACIÓN de CARGA de DATOS en iOS**](https://www.youtube.com/watch?v=Zx1Pg1gPfxA) by MoureDev
|
||||
|
||||
|
||||
## 📲 Installation
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SkeletonView"
|
||||
s.version = "1.25.0"
|
||||
s.version = "1.25.1"
|
||||
s.summary = "An elegant way to show users that something is happening and also prepare them to which contents he is waiting"
|
||||
s.description = <<-DESC
|
||||
Today almost all apps have async processes, as API requests, long runing processes, etc. And while the processes are working, usually developers place a loading view to show users that something is going on.
|
||||
|
||||
@@ -67,7 +67,8 @@ struct SkeletonLayer {
|
||||
multilineSpacing: textView.multilineSpacing,
|
||||
paddingInsets: textView.paddingInsets,
|
||||
alignment: textView.textAlignment,
|
||||
isRTL: holder?.isRTL ?? false)
|
||||
isRTL: holder?.isRTL ?? false,
|
||||
shouldCenterVertically: textView.shouldCenterTextVertically)
|
||||
|
||||
maskLayer.addMultilinesLayers(for: config)
|
||||
}
|
||||
@@ -82,7 +83,8 @@ struct SkeletonLayer {
|
||||
multilineSpacing: textView.multilineSpacing,
|
||||
paddingInsets: textView.paddingInsets,
|
||||
alignment: textView.textAlignment,
|
||||
isRTL: holder?.isRTL ?? false)
|
||||
isRTL: holder?.isRTL ?? false,
|
||||
shouldCenterVertically: textView.shouldCenterTextVertically)
|
||||
|
||||
maskLayer.updateMultilinesLayers(for: config)
|
||||
}
|
||||
|
||||
+2
-1
@@ -24,7 +24,8 @@ struct SkeletonMultilinesLayerConfig {
|
||||
var paddingInsets: UIEdgeInsets
|
||||
var alignment: NSTextAlignment
|
||||
var isRTL: Bool
|
||||
|
||||
var shouldCenterVertically: Bool
|
||||
|
||||
/// Returns padding insets taking into account if the RTL is activated
|
||||
var calculatedPaddingInsets: UIEdgeInsets {
|
||||
UIEdgeInsets(top: paddingInsets.top,
|
||||
|
||||
@@ -23,6 +23,7 @@ protocol SkeletonTextNode {
|
||||
var multilineSpacing: CGFloat { get }
|
||||
var paddingInsets: UIEdgeInsets { get }
|
||||
var usesTextHeightForLines: Bool { get }
|
||||
var shouldCenterTextVertically: Bool { get }
|
||||
}
|
||||
|
||||
enum SkeletonTextNodeAssociatedKeys {
|
||||
@@ -79,6 +80,10 @@ extension UILabel: SkeletonTextNode {
|
||||
set { ao_set(newValue, pkey: &SkeletonTextNodeAssociatedKeys.backupHeightConstraints) }
|
||||
}
|
||||
|
||||
var shouldCenterTextVertically: Bool {
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension UITextView: SkeletonTextNode {
|
||||
@@ -129,4 +134,7 @@ extension UITextView: SkeletonTextNode {
|
||||
set { ao_set(newValue, pkey: &SkeletonTextNodeAssociatedKeys.paddingInsets) }
|
||||
}
|
||||
|
||||
var shouldCenterTextVertically: Bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +188,19 @@ extension CALayer {
|
||||
isRTL: config.isRTL
|
||||
)
|
||||
}
|
||||
|
||||
guard config.shouldCenterVertically,
|
||||
let maxY = currentSkeletonSublayers.last?.frame.maxY else {
|
||||
return
|
||||
}
|
||||
let verticallyCenterAlignedFrames = currentSkeletonSublayers.map { layer -> CGRect in
|
||||
let moveDownBy = (bounds.height - (maxY + paddingInsets.top + paddingInsets.bottom)) / 2
|
||||
return layer.frame.offsetBy(dx: 0, dy: moveDownBy)
|
||||
}
|
||||
|
||||
for (index, layer) in currentSkeletonSublayers.enumerated() {
|
||||
layer.frame = verticallyCenterAlignedFrames[index]
|
||||
}
|
||||
}
|
||||
|
||||
func updateLayerFrame(for index: Int, totalLines: Int, size: CGSize, multilineSpacing: CGFloat, paddingInsets: UIEdgeInsets, alignment: NSTextAlignment, isRTL: Bool) {
|
||||
|
||||
Reference in New Issue
Block a user