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

Add corner radius for skeletonView as IBInspectable (CGFloat) default is 0.0 #271

Merged
merged 3 commits into from
Mar 19, 2020
Merged
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
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ All notable changes to this project will be documented in this file
#### 🙌 New

#### 🔬Improvements

* [**271**](https://github.com/Juanpe/SkeletonView/pull/271): Add corner radius for skeletonView as IBInspectable (CGFloat) default is 0.0 - [@paulanatoleclaudot-betclic](https://github.com/paulanatoleclaudot-betclic)

#### 🩹 Bug fixes

### 📦 [1.8.6](https://github.com/Juanpe/SkeletonView/releases/tag/1.8.6)
Expand All @@ -17,7 +18,7 @@ All notable changes to this project will be documented in this file
* [**263**](https://github.com/Juanpe/SkeletonView/pull/263): Feature/set cross dissolve transitions as default - [@Juanpe](https://github.com/Juanpe)
* [**264**](https://github.com/Juanpe/SkeletonView/pull/264): not replace original datasource is running XCTests - [@Juanpe](https://github.com/Juanpe)
* [**265**](https://github.com/Juanpe/SkeletonView/pull/265): call original traitCollectionDidChange method - [@Juanpe](https://github.com/Juanpe)

#### 🩹 Bug fixes
* [**260**](https://github.com/Juanpe/SkeletonView/issues/260): Don't hide skeleton layers on TableViewHeaderFooterView
* [**257**](https://github.com/Juanpe/SkeletonView/issues/257): Unit test problem when using SkeletonView
Expand All @@ -30,15 +31,15 @@ All notable changes to this project will be documented in this file
### 📦 [1.8.2](https://github.com/Juanpe/SkeletonView/releases/tag/1.8.2)

#### 🙌 New
- Add ability to customize line spacing per label. (thanks @gshahbazian)
- Add ability to customize line spacing per label. (thanks @gshahbazian)

### 📦 [LayoutSkeleton (1.8.1)](https://github.com/Juanpe/SkeletonView/releases/tag/1.8.1)

#### 🔬Improvements
- Fix completion call in .none transition style while hide skeletons. (thanks @aadudyrev)

#### 🙌 New
- Swizzle `layoutSubviews` method.
- Swizzle `layoutSubviews` method.

#### 🔬Improvements
- Fix completion call in .none transition style while hiding skeletons. (thanks @aadudyrev)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ Default values:
- *default: 70*
- **multilineCornerRadius**: Int
- *default: 0*
- **skeletonCornerRadius**: CGFloat (IBInspectable) (Make your skeleton view with corner)
- *default: 0*

To get these default values you can use `SkeletonAppearance.default`. Using this property you can set the values as well:
```Swift
Expand Down
1 change: 1 addition & 0 deletions Sources/Extensions/UIView+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum ViewAssociatedKeys {
static var labelViewState = "labelViewState"
static var imageViewState = "imageViewState"
static var currentSkeletonConfig = "currentSkeletonConfig"
static var skeletonCornerRadius = "skeletonCornerRadius"
}
// codebeat:enable[TOO_MANY_IVARS]

Expand Down
11 changes: 11 additions & 0 deletions Sources/Extensions/UIView+IBInspectable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ public extension UIView {
get { return skeletonable }
set { skeletonable = newValue }
}

@IBInspectable
var skeletonCornerRadius: Float {
get { return skeletonableCornerRadius }
set { skeletonableCornerRadius = newValue }
}

var isSkeletonActive: Bool {
return status == .on || (subviewsSkeletonables.first(where: { $0.isSkeletonActive }) != nil)
Expand All @@ -17,5 +23,10 @@ public extension UIView {
get { return ao_get(pkey: &ViewAssociatedKeys.skeletonable) as? Bool ?? false }
set { ao_set(newValue ?? false, pkey: &ViewAssociatedKeys.skeletonable) }
}

private var skeletonableCornerRadius: Float! {
get { return ao_get(pkey: &ViewAssociatedKeys.skeletonCornerRadius) as? Float ?? 0.0 }
set { ao_set(newValue ?? 0.0, pkey: &ViewAssociatedKeys.skeletonCornerRadius) }
}
}

1 change: 1 addition & 0 deletions Sources/SkeletonLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct SkeletonLayer {
self.maskLayer = type.layer
self.maskLayer.anchorPoint = .zero
self.maskLayer.bounds = holder.maxBoundsEstimated
self.maskLayer.cornerRadius = CGFloat(holder.skeletonCornerRadius)
addTextLinesIfNeeded()
self.maskLayer.tint(withColors: colors)
}
Expand Down