Juanpe / SkeletonView

☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting
MIT License
12.51k stars 1.1k forks source link

UILabel width skeleton fill problem #455

Closed kerimovscreations closed 2 years ago

kerimovscreations commented 2 years ago

Description

Skeleton fills 50% of the label's line if it is single line.

What type of issue is this? (place an x in one of the [ ])

Requirements (place an x in each of the [ ])


Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

SkeletonView Environment:

SkeletonView version: 1.25.1 Xcode version: 12.5.1 Swift version: 5

Steps to reproduce:

  1. Please an UILabel on your page, with full-width constraints.
  2. Try to call showAnimatedGradientSkeleton()
  3. Single line label will be filled only half of the width.

Expected result:

Skeleton view should fill the full-width of single line UILabel component

Actual result:

Skeleton view filled the half-width of single line UILabel component

selanthiraiyan commented 2 years ago

Hello @kerimovscreations :wave:

Are you setting lastLineFillPercent as 50 for this label?

Please note that lastLineFillPercent will also be applied to single line labels as well. Kindly refer to the table, in this section of README - https://github.com/Juanpe/SkeletonView#-texts More info - https://github.com/Juanpe/SkeletonView/issues/430

BTW, the default fallback value for lastLineFillPercent is, multilineLastLineFillPercent from SkeletonViewAppearance which is set as 70. It could be affecting your label as well.

kerimovscreations commented 2 years ago

Hello @selanthiraiyan

I didn't set any value for the property lastLineFillPercent. I agree it can be 70 (I measured objectively by my glance).

Thanks for the response, I guess it causes extra parameters for every single label to set the gradient width to fill the full space.

selanthiraiyan commented 2 years ago

You can change the default appearance value from 70 to 100 by doing the following.

SkeletonAppearance.default.multilineLastLineFillPercent = 100

Of course, you can customise (override) this value for specific labels and textviews if needed, by changing the lastLineFillPercent value of those individual views.

kerimovscreations commented 2 years ago

Thanks for the tips!

Juanpe commented 2 years ago

Thank @selanthiraiyan for the answers 👍🏼