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.59k stars 1.11k forks source link

The UILabel doesn't consider the font line height while showing skeleton #426

Closed ankitagarwal007 closed 3 years ago

ankitagarwal007 commented 3 years ago

Description

The UIlabel takes the line-height of either the height constraint or the line SkeletonViewAppearance.multilineHeight It doesn't consider the font line height as considered in UITextView. This is causing issues in the ios 12 version as the text behind the skeleton is visible. Also on versions >=13.0 the font line height is not considered so all the labels are of the same height

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.21.2 Xcode version: 12.5.1 Swift version: 5.1

Steps to reproduce:

  1. Create a UILabel and enable its Skeleton
  2. Put font of System 24.0

Expected result:

Skeleton View should be according to the line height of the font. Code should be similar to UITextview+Multiline.swift line-height property

Actual result:

iOS 12.0 : The text behind is showing iOS >=13.0 : UIlabel skeleton height is equal to SkeletonViewAppearance.multilineHeight

Attachments:

iOS 12.0 Simulator Screen Shot - iPhone X - 2021-08-10 at 02 32 15

iOS >=13.0 Simulator Screen Shot - iPhone X - 2021-08-10 at 02 32 00

Expected on all iOS Versions

Simulator Screen Shot - iPhone X - 2021-08-10 at 01 59 44

Juanpe commented 3 years ago

Hi @ankitagarwal007, thanks for opening this issue. I can't reproduce it 🤔 I realized that you're using version 1.8.2 and the latest version is 1.21.2. Please, could you update the dependency? I think this issue is already solved :)

ankitagarwal007 commented 3 years ago

@Juanpe I have mentioned the wrong version. I am using the latest version 1.21.2. I dug a Lil deeper and I found that if I use a color from color. xcassets it is replicating and if I use any color directly than it is showing fine but with a fixed height of SkeletonViewAppearance.multilineHeight

I have tried it on 12.2 iPhone X, and I have also raised a PR for the fix. If you see the PR we haven't consider font line height anywhere like we have done it for UITextView.

Juanpe commented 3 years ago

It's so weird 🤔 could you provide me a simple project?

ankitagarwal007 commented 3 years ago

SkeletonDemo.zip @Juanpe Attached a simple project

Juanpe commented 3 years ago

Thanks for the project. It's mind-blowing 🤯 I'm checking but as you said, the problem is if the label text color is defined in a xcasset, the frame is different

Juanpe commented 3 years ago

I was investigating and the problem is in iOS 12, when you use a color asset, the color is set when the view is displayed, so this method override the color assigned by the library. I'm checking if the method layoutSubviews could be useful to replace this color :/

Juanpe commented 3 years ago

Solved by #427