UIProgressView not reflecting first 0.05 of progress - ios

It seems to me that when setting a UIProgressViews progress to a value between >0.0 and 0.05 always shows a progress of 0.05 (no matter the value).
I understand that this makes sense from a UX perspective, but does UIProgressView have a property to turn it off?

Judging from the PlayGround below and from #Rohan Bhale's comment, UIProgressView scales it's progress layer according to the view's frame size. The smaller the width, the less difference you will see at small .progress ranges.
At 200 points width (as depicted below), there are in fact noticeable differences in your 0 .. 0.05 range.

Related

ScrollView.contentOffset.y can't move less than 0.333 pixel

I'm trying to create a teleprompter. Basically auto scrolling scrollView.
I'm moving my scrollView.contentOffset.y by 1 point/pixel every X time.
I'm giving the user the option to slow the animation down, and I want to do it by moving fewer points, not by increasing the time it takes to call for each pixel movement.
But I can't reduce the point size to less than 0.3333. When calling for a movement of 0.2 it's rounded up to 0.333, 0.1 is rounded down to 0 so I'm getting 0 movement. Why is that and how can I change it?
The offset is in points. On a 3x device, a single pixel is 0.3333 points. Obviously you can't scroll a partial pixel.
One solution that effectively gets around this issue is for you to keep your own value for the offset that you can increment in smaller values. Then update the scroll view's offset with your own running value. Don't try to add something like 0.1 or 0.2 to the scroll view's offset. Increment your own value and update the scroll view's offset. Of course the actual movement of the scroll view won't be as fined grained as your little updates but the overall scrolling will be slower.

ProgressHUD width size not changing UI

As I continue working on my fitness app to add features, I stumble occasionally. I am having difficulty getting the ProgressHUD to update the view size. I know that a value is sent to the properties of the view but the width does not change in the UI. Here is the code I'm using for updating.
// linked to view that needs to change size when progressHUD is updated
#IBOutlet weak var progressHUD: UIView!
// this is set inside a timer that fires every 20 seconds and should update progressHUD
progressHUD.frame.size.width = (view.frame.size.width/10) * CGFloat((userHeartRate/Double(maxHeartRate)))
Here is the GUI:
The app gets the users current heart rate, compares it to the maximum heart rate to get a percentage of the maximum heart rate. This percentage is represented by the progressHUD (gray bar beneath Warm Up) and should move to the right based on the percentage of the maximum heart rate.
I know that the values are calculating correctly and assigning the value to progressHUD.frame.size.width but the gray bar does not reflect the value assigned to it.
I have installed the cocoapod for ProgressHUD and I believe everything to be working correctly. (There were no errors on the install)
There must be something simple that I am overlooking!
Any help provided is greatly appreciated.
You seem to have an unnecessary divide by 10 in your formula.
If you want progressHUD to vary from 0% to 100% of the width of the view's frame. then you should do:
progressHUD.frame.size.width = view.frame.size.width * CGFloat(userHeartRate)/CGFloat(maxHeartRate)
Assuming userHeartRate doesn't exceed maxHeartRate, then CGFloat(userHeartRate)/CGFloat(maxHeartRate) is a value between 0.0 and 1.0. Multiplying that the the view's width gives a value 0% to 100% of the view's width.
You might want to throw in a max() function if userHeartRate can exceed maxHeartRate:
progressHUD.frame.size.width = view.frame.size.width * max(1.0, CGFloat(userHeartRate)/CGFloat(maxHeartRate))
Since your progressHUD view is laid out in the Storyboard, you might want to use Auto Layout to size it. Get an outlet to the constraint for the view's width:
#IBOutlet weak var progressHUDwidth: NSLayoutContraint!
Then update it by setting its constant property:
progressHUDwidth.constant = view.frame.size.width * ...

XCode iOS UISlider - Custom Scaling Min and Max

I want to have a different scale using a slider for the Min and Max. 0 should be in the middle, but I want to have a scale 0-50 for max and -200-0 for min.
Is that possible? How could I achieve that?
I don't think that this is possible out of the box.
But what you can do is, e.g. setup the slider in a way that for min it has 0 and for max 1000. Now you will have to check in which part of the part, user left the slider. If it's in the lower half, you will have to normalize those values to the desired range, the same for the upper range. The exact middle could be a bit tricky because you will have more points in the slider than in the ranges you are providing, but I guess with some fiddling around you can do this. :)
Hope that helped :)
I believe this is quite possible.
Here is my idea of how you can do it
Take a slider with values -200 to 200
For values > 0. Divide value by 4. (i.e. 200 / 4 = 50)
This will make your positive range from 0 to 50 but negative range from -200 to 0
Similarly while setting value to slider in positive manner you can multiply it by 4.

Core Plot - Very Low Frame Rate with Bar Plot on iPhone 5

I have 390 points on my plot. The Frame rate is < 20 fps during pinch-zoom with both the scatter and bar plot. However if I only have a scatter plot on screen, i get ~50fps. When i used instruments, the main bottleneck seems to the -[CPTBarPlot renderAsVectorInContext:] which has a run time of more than 50% where as scatter plot is <20%. Even when i plotted only the bar plot on screen, I cldn't get more than 20fps (but i still need to test it) . Is this the std performance of a bar plot? How can i improve this? I have already set the cache precision to be double.
I'll appreciate if someone can help me here.
Thanks.
make sure the barCornerRadius and barBaseCornerRadius have the default value of zero. Set the barWidth to zero. Set barWidthsAreInViewCoordinates to YES to speed up coordinate conversions. Set the fill to nil.

Problem with a vertical UISlider with custom images

So i have a custom UISlider. It's vertical (i did it with the +270° technic). I have 3 images, respectively for the minimum value, maximum value and for the thumb. Everything seems good but i have problems with the extrema values, as you can observe on the screen capture (even though it's a little dark).
The slider on the left is perfect ! Both end of the sliders show the images perfectly and the cursor (thumb) is perfectly cutting the slider in 2.
The other two sliders on the right shows a similar issue. We can see that, when in extrema value, the cursor is not well located (there shouldn't be any part of the image below or above the middle of the cursor !) Oo
More to that, let's look at the right slider (with minimum value). We can see that image has been cut on the bottom ! Indeed it should be close. It's the same thing for the maximum value, the image looks like it's been cut.
I looked at the bounds of the slider view by touching it at both ends and looking at its coordinates. The slider was defined with a height of 300 but i can perform touches at coordinate 307, or -6 !!! I don't really understand why..
For more information, coordinates form 300 to 310 represents the maximum value i defined and negative coordinates (from 0 to -10) represents the minimum value.
-> So We can notice there's a difference of 10 at both ends.
Please help ! :s

Resources