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

can we set image (dynamic size --> fit to slice segment frame) and text in center for slice for any no. of slices in wheel? #18

Closed
kishanbh opened this issue Jun 1, 2021 · 5 comments

Comments

@kishanbh
Copy link

kishanbh commented Jun 1, 2021

Hi, is it possible to set image (dynamic size --> fit to slice segment frame) and text in the center of the slice for any no. of slices in the wheel? I actually tried and get the following output but not able to set image and text in the center but with a vertical offset, we can not get desired output. Any help would be appreciated. can you provide some guidance?
wheel_image

@sh-khashimov
Copy link
Owner

Yes.

@kishanbh
Copy link
Author

kishanbh commented Jun 2, 2021

@sh-khashimov can we handle slice text ad image with vertical offset in the center of the slice of the wheel or with something else can you provide some suggestion or help then it will be helpful.

@sh-khashimov
Copy link
Owner

Did you try set TextPreferences.alignment to .center?
You can set your image as a slice' background. You cannot change background image offset, try to change your image size instead.

@kishanbh
Copy link
Author

kishanbh commented Jun 2, 2021

@sh-khashimov thanks for the quick reply,

I'm using these for slice configuration like in your library example

let sliceContent = [Slice.ContentType.assetImage(name: prize.imageName, preferences: .variousWheelPodiumImage),
                                Slice.ContentType.text(text: prize.name, preferences: .variousWheelPodiumText(textColor: prize.textColor))]
var slice = Slice(contents: sliceContent, backgroundColor: prize.color)

Wherein background color I set UIColor with pattern image for square purple layer

With these, it can be possible to get desired output?

is there any option for a set size of image for a background image? like imageSize preferences because I'm setting image dynamically with a slice width

e.g., if there is only 4 slice then set cross image according to slice's frame

@sh-khashimov
Copy link
Owner

Take a look at the example project, which you can see at BackgroundImageExampleViewController.swift.
You should set the image to backgroundImage, not a backgroundColor to the Slice.
Then you can change content mode for background image at fortuneWheel.configuration?.wheelPreferences.slicePreferences.backgroundImageContentMode.

@kishanbh kishanbh closed this as completed Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants