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.
Related
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.
I am using PanGesture Recognizer in Swift for iOS. Inside the action method, I am calling 3rd party method, that takes move direction and speed. From this, it calculates position of object:
objectPos += normalize(move) * speed
Problem is, that if I put my finger on a certain object and move with fingers, objects is not at the same position under my finger. It starts to move slower / faster. Moving directions are OK. Problem is with acceleration / decceleration - if I move faster, objects move faster.
In gesture callback I have tried:
let move = recognizer.translation(in: self.view);
let speed = sqrt((move.x * move.x) + (move.y * move.y));
and
let move = recognizer.velocity(in: self.view);
let speed = dt * sqrt((move.x * move.x) + (move.y * move.y));
Usually dt = 1.0 / 60.0. It is the gesture callback refresh rate (in code, I am calculating dt manually using difference of CFAbsoluteTimeGetCurrent()). Without this, If I use velocity directly to calculate speed, movement is too fast.
I have tried to calculate difference manually by subtracting current and last position, but still no luck.
I have also tried to "change speed" accoring to current view width and height, but none ot if worked. I am probably missing something, but dont know what.
It would be easier if you just computed the moves of the object based on acceleration when the user stops touching the object.
As long as the user has their finger on the object, it is much easier to just set the position of the object to the position you get from the pan gesture recognizer.
Ok... I have found the problem. Movement of th eobject it in screen normalized coordinates with corners [0,0] - [1,1]. So movement in Y axis (height) was correct, but in X axis (width) the speed was about half.
Multiply move.x with correct aspect ratio solved the problem. Basically, the moevement in X axis is enlarged manually.
I am trying raise the height of the ranked successive views. There is a certain distance between each of these views.(Vertical spaces)When I increase the height of one of them, distorted distance between the bottom. I can not align all elements under one single at a time. This event is automatically done on Android. How do I make this operation on iOS.
That is the problem
I have a UIView with a height of 100 and a width of 50. I am then rotating the view 45 degrees. After I rotate the view, then frame increase. How Can I determine If a point lies inside the view.
If I just compare the frame to the point I will get a false positives when the point is off the view but still in the frame. I want to see if the point is in the initial 50x100 rotated view.
Right Now I am getting the height of the point in relation to the view. Then I am using said height to calculate the distance from the left wall; I calculate the length to the side using the fact that is is a 45-45-90 triangle. Using this distance I am checking is the point.x is within the acceptable variance. This method is off as the point moves up and to the right.
Is there a built in function that will give a BOOL or framework. Or what am I doing wrong in my formula.
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