SvenTiigi / WhatsNewKit

Showcase your awesome new app features 📱
https://sventiigi.github.io/WhatsNewKit/
MIT License
3.92k stars 193 forks source link

How to fix Layout Error while using WhatsNewKit Library in Swift 5? #39

Closed christophriepe closed 4 years ago

christophriepe commented 4 years ago

Hey,

I ran into an error while using WhatsNewKit. I posted a Question on StackOverflow. Here is the link: https://stackoverflow.com/questions/61372170/how-to-fix-layout-error-while-using-whatsnewkit-library-in-swift-5

Can you think of a reason why this is happening to me?

Thanks a lot for your help in advance.

SvenTiigi commented 4 years ago

Hey @christophriepe,

it seems like you are using a non transparent image or loading the UIImage via the provided name fails this is why the image get tinted in its full bounds.

If you want to disable the default autoTintImage behaviour you can simply change the ItemsView configuration.

configuration.itemsView.autoTintImage = false

As the ItemsView is centered it seems like you are setting the ItemsView.ContentMode to .center the default behaviour as seen in the example application is .top.

// ContentMode Top
configuration.itemsView.contentMode = .top

// ContentMode Center
configuration.itemsView.contentMode = .center

// ContentMode Fill
configuration.itemsView.contentMode = .fill

Please provide a code snippet of your WhatsNewViewController configuration and presentation in order to identify the misconfiguration.

christophriepe commented 4 years ago

Thanks for your answer @SvenTiigi.

Here is my code for the configuration:

let theme = WhatsNewViewController.Theme { configuration in
    configuration.completionButton.backgroundColor = UIColor.yellow
    configuration.completionButton.titleColor = UIColor.black

    configuration.itemsView.contentMode = .top
}
let config = WhatsNewViewController.Configuration(theme: theme)

I now chose the example images in the Example folder but this wasn't the issue. It is still looking the same way as before.

Bildschirmfoto 2020-04-23 um 18 06 48

To see the whole source code for this WhatsnewViewController see the linked StackOverflow Question, as well as for the error messages. https://stackoverflow.com/questions/61372170/how-to-fix-layout-error-while-using-whatsnewkit-library-in-swift-5

I hope you guys can see something I can't. Thanks a lot for your help in advance.

SvenTiigi commented 4 years ago

Hey @christophriepe,

I've created an example app and added your provided code snippet.

Bildschirmfoto 2020-04-23 um 18 47 40

The ItemsView is correctly displayed at the top position. Please try the same with a small example app to encapsulate the bug.

It might be that somewhere in your code the ItemsView Configuration gets set to center.

christophriepe commented 4 years ago

Thanks for your answer @SvenTiigi, that fixed the first problem I had.

However in all examples the Item View takes the whole available space like in the image below:

Bildschirmfoto 2020-04-23 um 18 56 21

Why is my Item View (or the one in the example app of your last post) only taking more or less a quarter of The available space?

Is there any configuration to let the Item View fill out all the available space?

SvenTiigi commented 4 years ago

To fill the available space along the axis

configuration.itemsView.contentMode = .fill

https://github.com/SvenTiigi/WhatsNewKit#contentmode-

Additionally, you can make use of the Insets API to modify the size of the ItemsView

https://github.com/SvenTiigi/WhatsNewKit#insets

christophriepe commented 4 years ago

Thanks, @SvenTiigi, its working now!