uislider

UISlider and UIScrollView

泪湿孤枕 提交于 2019-11-28 17:06:21
I have a UISlider as part of a view that is loaded into a UIScrollView with paging enabled. I've noticed an unexpected behavior. If the user tries to use the slider quickly (i.e. press and move) it "activates" the scroll view, causing the page to switch. However, if your press and hold for a second the slider "activates" and you can then adjust the slider value. This behavior is undesirable. What is the best way to make the UISlider responsive when loaded into a UIScrollView ? I've thought about adding a "blocker" view that just eats up touch events that is placed under the slider, but not

How to put UISlider vertical?

…衆ロ難τιáo~ 提交于 2019-11-28 16:31:05
I want to put UISlider in vertically. I have no idea about this, so please help me for this. You have to do this programaticaly. Assuming your UISlider is bound to a variable called slider , add this code in your viewDidLoad method in ViewController.m: - (void)viewDidLoad { [super viewDidLoad]; CGAffineTransform trans = CGAffineTransformMakeRotation(M_PI * 0.5); slider.transform = trans; } Let me know if you need any more help on this.. As of Xcode 4.2, you can sort of do the same in Interface Builder. Create a slider Show the "Identity Inspector" Add a "User Defined Runtime Attribute" Set the

Implementing steps/snapping UISlider

江枫思渺然 提交于 2019-11-28 15:36:47
问题 I am trying to implement some form of snapping or steps with the UISlider. I have written the following code but it does not work as smooth as I hoped for. It works, but when the I slide it upwards it snap 5points to the right leaving the finger not centered over the "slide-circle" This is my code where self.lastQuestionSliderValue is a property of the class which I have set to the initial value of the slider. if (self.questionSlider.value > self.lastQuestionSliderValue) { self.questionSlider

UISlider that snaps to a fixed number of steps (like Text Size in the iOS 7 Settings app)

独自空忆成欢 提交于 2019-11-28 15:12:40
I'm trying to create a UISlider that lets you choose from an array of numbers. Each slider position should be equidistant and the slider should snap to each position, rather than smoothly slide between them. (This is the behavior of the slider in Settings > General > Text Size , which was introduced in iOS 7.) The numbers I want to choose from are: -3, 0, 2, 4, 7, 10, and 12. (I'm very new to Objective-C, so a complete code example would be much more helpful than a code snippet. =) matsr Some of the other answers work, but this will give you the same fixed space between every position in your

Customizing UISlider look

家住魔仙堡 提交于 2019-11-28 11:09:27
To customize the visual look of a UISlider you can set the thumb and track images. Part of the track images gets stretched to the appropriate with. From the documentation: A stretchable region sits between two end cap regions. The end caps define the portions of the image that remain as is and are not stretched. The stretchable region is a 1-point wide area between the end caps that can be replicated to make the image appear longer. Now the problem I have is that my stretchable region needs to be more than 1-point wide. (It's a pattern) Unfortunately the 1-point width seems to be hard coded in

Customize UISlider (track image height)

孤街浪徒 提交于 2019-11-28 11:02:05
I'm customizing a UISlider . I could set a custom thumb image that is higher than the usual thumb however I could not make the track higher when setting a higher minimum track image but the track height remained the same. It should be possible as in the iPod/Music App on the iPad the volume slider is also higher as the usual slider as you can see here: (source: cocoia.com ) You need to subclass the slider and override the trackRectForBounds: method, like this: - (CGRect)trackRectForBounds:(CGRect)bounds { return bounds; } The simplest solution for Swift: class TBSlider: UISlider { override

iPhone:Programming UISlider to position at clicked location

旧街凉风 提交于 2019-11-28 08:45:26
How to set the slider to clicked position and get the slider value on the clicked location on UISlider in iPhone programming. i know we can drag the slider to that position but i dont want to do it. Can you please tel me how to set the slider to clicked position? Is this possible to do? Here is the part "left as a user exercise": - (void) tapped: (UITapGestureRecognizer*) g { UISlider* s = (UISlider*)g.view; if (s.highlighted) return; // tap on thumb, let slider deal with it CGPoint pt = [g locationInView: s]; CGFloat percentage = pt.x / s.bounds.size.width; CGFloat delta = percentage * (s

UISlider setMaximumTrackTintColor in iOS 7.1

笑着哭i 提交于 2019-11-28 07:37:09
[slider setMaximumTrackTintColor: color] has unexpected results in iOS 7.1 (the slider bar changes its position appearing at top instead of vertical center or disappears completely), while working fine with prior versions. [slider setMinimumTrackTintColor: color] does render the expected result. This question might be related: UISlider setMaximumTrackTintColor , but no answer so far. Update: I get this: instead of: Update #2: Using setMaximumTrackImage might work, but the solution I'm looking for is a way to set any random color and not a preexisting image. Update #3: This issue is still

Increment UISlider by 0.2 in range 0 to 2.0 [duplicate]

痞子三分冷 提交于 2019-11-28 06:42:42
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Increment UISlider by 1 in range 1 to 100 I am new to iPhone, How do I have my UISlider go from 0 to 2 in increments of 0.2? slider = [[UISlider alloc] init]; [slider addTarget:self action:@selector(sliderChange:) forControlEvents:UIControlEventValueChanged]; [slider setBackgroundColor:[UIColor clearColor]]; slider.minimumValue = 0.0; slider.maximumValue = 2.0; slider.continuous = YES; slider.value = 0.0; -

Make UISlider height larger?

江枫思渺然 提交于 2019-11-28 06:16:00
I've been searching for a way to make the UISlider progress bar taller, that is, increase the height. However, I haven't had any success. I don't want to use a custom image or anything, just make it taller, so the UISlider doesn't look so thin. Am I missing something super obvious? The accepted answer will undesirably change the slider's width in some cases, like if you're using a minimumValueImage and maximumValueImage . If you only want to change the height and leave everything else alone, then use this code: override func trackRect(forBounds bounds: CGRect) -> CGRect { var newBounds = super