How to get the center of the thumb image of UISlider

This will return the correct X position of center of thumb image of UISlider in view coordinates: – (float)xPositionFromSliderValue:(UISlider *)aSlider { float sliderRange = aSlider.frame.size.width – aSlider.currentThumbImage.size.width; float sliderOrigin = aSlider.frame.origin.x + (aSlider.currentThumbImage.size.width / 2.0); float sliderValueToPixels = (((aSlider.value – aSlider.minimumValue)/(aSlider.maximumValue – aSlider.minimumValue)) * sliderRange) + sliderOrigin; return sliderValueToPixels; } Put it in your view … Read more

UISlider with increments of 5

Add a target like this: slider.continuous = YES; [slider addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged]; And in the valueChanged function set the value to the closest value that is divisible by 5. [slider setValue:((int)((slider.value + 2.5) / 5) * 5) animated:NO]; So if you need any interval other than 5 simply set it like so: float interval = … Read more

Change iPhone UISlider bar image

You were right to use -setMinimumTrackImage:forState: and -setMaximumTrackImage:forState: methods. What you missed is that you should provide stretchable UIImage to them, the rest is taken care of automagically: UIImage *sliderLeftTrackImage = [[UIImage imageNamed: @”SliderMin.png”] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0]; UIImage *sliderRightTrackImage = [[UIImage imageNamed: @”SliderMax.png”] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0]; [mySlider setMinimumTrackImage: sliderLeftTrackImage forState: UIControlStateNormal]; [mySlider setMaximumTrackImage: … Read more

Slide a layout up from bottom of screen

Use these animations: bottom_up.xml <?xml version=”1.0″ encoding=”utf-8″?> <set xmlns:android=”http://schemas.android.com/apk/res/android”> <translate android:fromYDelta=”75%p” android:toYDelta=”0%p” android:fillAfter=”true” android:duration=”500″/> </set> bottom_down.xml <?xml version=”1.0″ encoding=”utf-8″?> <set xmlns:android=”http://schemas.android.com/apk/res/android”> <translate android:fromYDelta=”0%p” android:toYDelta=”100%p” android:fillAfter=”true” android:interpolator=”@android:anim/linear_interpolator” android:duration=”500″ /> </set> Use this code in your activity for hiding/animating your view: Animation bottomUp = AnimationUtils.loadAnimation(getContext(), R.anim.bottom_up); ViewGroup hiddenPanel = (ViewGroup)findViewById(R.id.hidden_panel); hiddenPanel.startAnimation(bottomUp); hiddenPanel.setVisibility(View.VISIBLE);