sh-khashimov / SwiftFortuneWheel

The ultimate spinning wheel view that supports dynamic content and rich customization.
MIT License
351 stars 82 forks source link

Can we apply gradient color to Slice and apply gradient color for Slice's Text? is it possible with some customization? #16

Closed kishanbh closed 3 years ago

sh-khashimov commented 3 years ago

With some modification, it's possible to apple gradient color to Slice's background. I add this in the future release. However, if you need a fast solution, here is a file that updated for gradient: Simulator Screen Shot - iPhone 12 - 2021-06-01 at 11 00 40

SliceDrawing.swift.zip

About Text gradient, unfortunately, there is no easy solution.

kishanbh commented 3 years ago

With some modification, it's possible to apple gradient color to Slice's background. I add this in the future release. However, if you need a fast solution, here is a file that updated for gradient: Simulator Screen Shot - iPhone 12 - 2021-06-01 at 11 00 40

SliceDrawing.swift.zip

About Text gradient, unfortunately, there is no easy solution.

@sh-khashimov can we apply gradient-like marked (radial gradient) in the attached image for the slice and applying for some slice only not all slice in the wheel? wheel

kishanbh commented 3 years ago

@sh-khashimov do you have any suggestions or thoughts about radial gradient for slice then it will be helpful.

sh-khashimov commented 3 years ago

change the code above that I gave you to:

context.drawLinearGradient(
              gradient,
            start: CGPoint(x: path.boundingBox.minX, y: path.boundingBox.midY),
              end: CGPoint(x: path.boundingBox.maxX, y: path.boundingBox.midY),
            options: []
            )
        //MARK: - Gradient Color END
kishanbh commented 3 years ago

@sh-khashimov thanks for the reply but it gives a gradient but from bottom to top like in between colors straight line I want radial like orange marked in the attached image is it possible? 1

sh-khashimov commented 3 years ago

instead of context.drawLinearGradient:

        context.drawRadialGradient(gradient,
                                   startCenter: center,
                                   startRadius: 0,
                                   endCenter: center,
                                   endRadius: radius,
                                   options: [])
kishanbh commented 3 years ago

@sh-khashimov got it, thanks for the reply and library. do you have any idea about the slice's text gradient or any file modification?

sh-khashimov commented 3 years ago

Unfortunately, no. Since gradient text is just an image inside the text, which adds complexity for already not an easy text processing inside the SwiftFortuneWheel. If you need to add a gradient text, my current advice, convert text to an image with gradient applied text, then add that image to your Slice.

kishanbh commented 3 years ago

@sh-khashimov thanks for the replay and all your help. Hope, in future version, we have gradient color option for text also