You can make your slider more beautiful by applying custom gradient colors to it.Have a look at following tricks we can use to colorful our UISlider object.
Import QuartzCore Framework.
Create an instance of UISlider and pass it with array of colors to set in to slider bar only after it has been instantiated successfully.
Gradient Set method is displaying below:----
Now Let us see what we have done in this method.
0)Get min_trackImageView and max_trackImageView object from subviews of UISlider object.
1)Create gradient Layers for min_trackImage and max_trackImage respectively.
2)Set layers frame to slider min_trackImage frame and max_trackImage properly along with changing x position of gradient layer.
3)Set its startPoint to Left and endPoint to right.
4)Using QuartzCore concept we set layers corner radius to 5.0;
5)Assign color array to gradient Layer and insert as subLayer to min_trackImageView and _max_trackImageView at index 0;
How to use it:-
Using this method is very simple . Just call this method with slider object and color array as parameter after UISlider Object has instanciated otherwise you will not see code reflection to your device or simulator.
Here is a piece of code displaying how to use it.---
And here is your output.
Import QuartzCore Framework.
Create an instance of UISlider and pass it with array of colors to set in to slider bar only after it has been instantiated successfully.
Gradient Set method is displaying below:----
Now Let us see what we have done in this method.
0)Get min_trackImageView and max_trackImageView object from subviews of UISlider object.
1)Create gradient Layers for min_trackImage and max_trackImage respectively.
2)Set layers frame to slider min_trackImage frame and max_trackImage properly along with changing x position of gradient layer.
3)Set its startPoint to Left and endPoint to right.
4)Using QuartzCore concept we set layers corner radius to 5.0;
5)Assign color array to gradient Layer and insert as subLayer to min_trackImageView and _max_trackImageView at index 0;
How to use it:-
Using this method is very simple . Just call this method with slider object and color array as parameter after UISlider Object has instanciated otherwise you will not see code reflection to your device or simulator.
Here is a piece of code displaying how to use it.---
And here is your output.
No comments:
Post a Comment