xcode and swift3 : vertical slider constraints - swift

I have made an application with 10 sliders which i rotate to vertical using:
slider1outlet.transform = CGAffineTransform.init( rotationAngle: CGFloat(-Double.pi / 2))
same for slider 2 thru 10
this works whitout a problem, but i want to add constraints so they go maximum height and are evenly distributed across the width of the screen, and they adapt when i rotate my screen.
this doesn't seem to work, the constraint seems to turn with the slider and i dont want that.
i have made screenshots (with only 3 sliders just for demo purposes)
the first slider has a red background to show what i mean, here is the screenshot of the application whitout rotating the sliders:
with the rotating sliders (only 1st slider has red background):

Related

How to animate UI position for different aspect ratio screens?

I know how to make a moving animation of an UI object, but how to make it supporting different aspect ratio screens?
For example, I have an UI object_1 in the left-lower corner and object_2 in the right-upper corner, both adjusted its position relative to the screen's corners. I want to make an UI image moving from object_1 to object_2.
The problem is that object_1 and object_2 are at different positions (even different ratio according to screen ratio) in different resolutions. Then how can I make the moving animation supporting different resolutions?
Thanks for any advice!
Screenshots:
1 Moving starting point where the left-lower checkbox is on 18:9 screen.
2 Moving ending point where the left-lower checkbox is on 18:9 screen.
3 Moving starting point, changed to 16:9 screen, and the screenshot shows that the position of the finger image does not match where the checkbox is.
4 Moving ending point on 16:9 screen, same problem with the above one.
OK, problem solved. It turns out the animation supports changing anchors at certain frames. So just turn on recording and adjust whatever you like.
In my project, first frame I set the finger image's anchor to the middle-lower point then record its position; when starts the moving animation, changes its anchor to middle-upper point then set the destination position. If the screen aspect ratio changes, since the animation also uses the right anchor data with the two check boxes, they'll match perfectly.
FYI, here's a screenshot of the animation window to help you understand.
This may help,
docs Unity3d site
This will support animations.

Rotation and constraints in swift3 (xcode)

I am using swift3 in xcode.
I have made an application with 10 sliders which I rotate to vertical using:
slider1outlet.transform = CGAffineTransform.init( rotationAngle: CGFloat(-Double.pi / 2))
Same goes for slider 2 through 10 this works without a problem,
but I want to add constraints so they go maximum height and are evenly distributed across the width of the screen, and they adapt when I rotate my screen.
This doesn't seem to work, the constraint seems to turn with the slider and I don't want that.
I have made screenshots (with only 3 sliders just for demo purposes)
the first slider has a red background to show what I mean, here is the screenshot of the application without rotating the sliders:
With the rotating sliders (only 1st slider has red background)
I had exactly the same problem, and it took me forever to figure out. I finally ended up writing my own class exactly for this: VerticalSlider.
Simply make new UISliders in your storyboard and set their classes to VerticalSlider.
It took me countless hours of trial and error in one of my projects to make that, so I'm glad I can finally help somebody else :D

Image View - Aligning image in centre on all devices on launchscreen

I'm new to iOS development. I'm trying to add logo on launchscreen in centre. I've a background with gradient colour so I've used a png file and stuck it in the background.
Next is logo which I want to centre for all devices.
I've two part questions
1) Is there anyway I can specify the constraints so that it is applicable to all devices? Example specifying top and bottom constraints in % ?
2) If above is not possible then how do I align logo in centre so that it works on all devices? Do I need to apply constraints separately on all devices?
I tried to set the width and height separately for all devices but it modifies dimensions on other devices. Not sure if this approach will work or I'm doping something wrong?
I'm aware that in worst case that I can just create launchscreens with logo in it as png and stick them for each devices separately which will work. I just wanted to know if it can be done with constraints.
Tx
As you suggested I added constraints to align it in centre horizontally and vertically. It seems to be good on one device but on other it's not. Please see images below.
And then how do I change image size?
One device
2nd device
You do have centerY and centerX constraints.
In storyboard, select the imageView that you have already added to your view. Right-clic drag to the main view (full screen view) in the left panel and choose center horizontally, repeat with center vertically.
You will need to also set the width and height constraints of your logo.
ALTERNATIVELY:
You don't need to clic drag, you can add the center constraints in the "add new alignment constraints" tab.
Finally I manage to solve what I Was looking for thanks to all those who helped. It was good learning period, 2 days in total ;)
Step 1: Align image to centre vertically and horizontally.
Step 2: Scale logo to fill the space. Please follow this video which is bang on point what I was looking for.
http://roadfiresoftware.com/2015/04/how-to-scale-an-image-view-based-on-device-size-with-auto-layout-in-interface-builder/

custom slider images xcode

I want to make a slider that is a line that is thin at the left (minimum)end and thick at the right (maximum) end and the button which slides between to change sizes between. I have tried setting minimum and maximum track images but this didn't seem to work. I have been able to set the images in IB but they stay the same size. Penultimate has something like I want when you pick the pen size. Any suggestions.

how to I scale an hour hand image to be small in Interface Builder (without moving center)?

How to I scale an hour hand image to be small in Interface Builder (without moving center)?
So I have:
Background clock face image
Arrow image that is about 30% to big, needs to be reduced
The Background clock face is set to: View Mode = ASPECT FIT (in IB). Plus resizes in each diretion.
I'm not sure what View Mode the Hour Hand should be at. I've currently set it to Centre, however in priciple I want it to resize (aspect resize) in relation to how much the clock face done during an orientation change.
When resizing it it would have to:
Not change the center of the image, as I've created the images such that they align well when centred together
Not be impacted by the "transformation" of the hour hand UIView which is how I move it around
Work for orientation changes