UISlider Custom Thumb Image Resizing Issue - ios

I want to get directions for following two issues related to UISlider control customization.
Issues#1:
I just updated the UISlideThumbImage as seen in following screenshot. As thumb image is in retina display, so its large image; My question is how we can resize the thumb image? I don't want to resize thumb image PNG. If i will do that then on retina display screens, it will seems blur.
Issue#2:
Default clickable area of thumb image of slider is 23x23. How we can increase that area? So that we can adjust it according to the size of thumb image. Currently, if i will move finger in 23x23 bounds, it will start sliding but if out side of that bound, it will not move but i also want to move the thumb if i will slide on any place of the thumb image.
Your important suggestions will be move helpful in this regards. Is there any third party library present which will do it more efficiently regardless of doing it ourself and spend more time over it?

From my experience with customising UISlider, It's better just not using the default one.
There is a open source Range Slider:
https://github.com/muZZkat/NMRangeSlider
And notice there is a option to remove the lower thumb so you acutely have a regular customising UISlider
"(New) Disable lower handle so it behaves like a regular UISlider but still use other features."

Related

Specific position of WKInterfaceImage alignment (Watch OS 2)

I just bought the Apple Watch and I want to create a super simple game for it.
It is simple enough to only use monochrome color scheme, but advanced enough to have an object moving in real-time.
I am trying to figure out how to position an object on my Apple Watch with Watch OS 2.
I want to place my object somewhere on the screen (anywhere I'd like to) but there are absolutely
no way to do that, I think.
But, in the following library: https://github.com/shu223/watchOS-2-Sampler
the developer can actually animate the alignment of the image so I guess
that itself suggests it should be possible to somehow specify a point of where to position an object.
And the animation is pretty smooth as well.
I have tried to generate frames on-the-fly CGContext which uses Quartz 2D, but it's way too slow and the app on my Apple Watch just crashes.
I don't necessarily think that the watch itself is too weak, but some clever programming should solve my problem, but I just cant figure out how to do it.
As you already said there is no way to directly position an WKInterfaceObject on your watch. You can change the alignment of an object but that leaves exactly 3 positions: left, center and right. Probably not enough for your game.
What you could do: You can set a background image on a WKInterfaceGroup. So you could draw your game objects into an UIImage and set that as background image of that group. That background images can also be animated. So maybe you can draw the movement of your game object into several UIImages and then set those as animated background image.
One way that I have found to have a little more control over where a WKInterfaceObject is on the screen is to add it to a parent WKInterfaceGroup, and center your item (vertically and/or horizontally depending on how you want to move it). Then you can tweak the group's relative height / width (setRelativeHeight and setRelativeWidth) and it's alignment (setVerticalAlignment and setHorizontalAlignment) to get your item positioned where you want.
This doesn't give you the ability to tweak frames or give the item a particular coordinate, but it does give you the ability to programmatically move a WKInterfaceObject anywhere on the screen.
For example if you want your object in the exact center of the screen vertically, you leave the group's relative height to its container as 1, with your item centered. To get the object at 40% from the top, you can change the group's relative height to 0.8 and it's alignment to .Top. If you want it 60% from the top, the relative height would still be 0.8, but the group's vertical alignment should be .Bottom etc.
I know this is kind of a confusing way to have to accomplish this, but this worked for me in getting items positioned exactly how I wanted.

How to detect the color of an UIImage in iOS

I have a view like this :
The left back button & the right button is basically two white image (set in UIButton) with a particular opacity. Now it's look more or less visible on this background cover photo.
But if I change the background cover photo with something else, where the opacity & color of that cover image is closer to the two button's image, then it's difficult to see those two button.
Like this:
So I just wondering, Is there any way, so that I can detect the color of my cover image and I can change those two buttons image or color according to it?
Any kind of reference or guidance would be very much appreciable.
I think you can use this function to determinate how light/dark is the background. Calculate an average of several pixel under your button.
Have fun! :D

ios frosted glass logic

Frosted Glass Effect
I'm thinking of how to approach this logically..
So we take the background image ( for example )
Then, we want to add our frosted glass button to this image. Here's how it should look..
Now I know I cannot programatically blur the background image of the button, so I'll to try and do it with two images.. Background.png and Backgorund_Blurred.png.
Now, the frosted glass effect will happen on animated objects. So, as they move across the screen, it should appear that it is blurring the background image behind it, however, to achieve this I can only think of one way. But doing so is beyond my current capability.
It would have to be a background_blurred image for the UIButton for example. No scaled in any way, and the exact same size as the normal background. Then, I would have to take the buttons relative position on the normal background and append the background_blurred of the button to suit.
My first question; is this possible?
Second question; is there an easier approach?
Lastly, I've added an image to make sense of the relative position theory.
Check out the FXBlur library, it'll let you blur images/views.. I've used it successfully and sounds like it'll do what you want.
I think having two images for these assets maybe easier, but having the views blur may be better in the long run as you wouldn't have to worry about updating the images for different resolutions in the future or care about how big the button is/will be.. Also if you want to do this with more images it'll turn into a mess with all the different images to manage.. The library is simple to use, with one call you'll have a blurred image/view..

UISlider - draw line / image to the track (bar)

I have UISlider with min and max track colors. I want to draw vertical line (or image) in the middle of the slider track. This line must be there the whole time, only color on top of it will be different (min / max track color).
If I put UIImage on the Slider background, tracks covers it. If I set clear color for tracks, I can see line, but no colors from tracks (obviously). Is there any simple way, how to do this, or I have to override drawRect method for Slider ?
Something like on the slider in image
Note that the sort of "ultimate" solution to this type of project is...
http://www.paintcodeapp.com
As #BradAllred pointed out, the fundamental problem here is: you are trying to avoid drawRect.
Realistically, you can only achieve your goal here by subclassing UIControl or slider.
As others have mentioned fortunately there are many great tutorials, etc, on doing this -- and it's not hard.
Once again paintcodeapp.com is kind of an "incredible secret" to making iOS apps, enjoy.
add an UIView that is 1 pixel wide and has the height of the Slider and put it over the slider.
Create a CALayer, draw it, (even add an image to it), then add that layer as a sublayer to the Slider's layer.contents.

What is the best way to draw skinnable "buttons" in a video game?

I'm looking for ideas on how to draw a skinnable "button" in a game application. If I use a fixed sprite non-vector image for the button background, then I can't size the button easily. If I write code to draw a resizable button (like Windows buttons are drawn), then the programmer has to get involved -- and it makes skinning difficult. Another option is to break the button into 9 smaller images (3x3) and stretch them all -- kindof like rounded corners are done in HTML.
Is there another "easier" way? What's the best approach?
If you really want to accomplish this, the way to do it is with texture coordinates. Much like you would make a stretchable button/panel design in HTML with a table, you simply define the UV coordinates for the corners, the top stretchable area, the bottom stretchable area, the side stretchable areas, and then the middle.
For an example of this being implemented in an XNA engine (though it's a closed source engine), see this:
http://www.flatredball.com/frb/docs/index.php?title=SpriteFrame_Tutorial
Yes. I am working on an Editor. It's a XAML-like language (or OpenLaszlo-like, if you prefer) for XNA. So the buttons can be resized by the editor. The buttons might also be resized by a style sheet.
I guess you're right that it's likely that the buttons will all be the same size in a real design. But even in a window's app, you sometimes need to make a button wider to accomodate text.
It should be possible with shaders. You would probably have to do texel lookups, but it would cut down on the number of triangles in a complex UI.

Resources