Manual positioning from a float value in iOS
-
21-06-2021 - |
Question
I've currently got an item positioned using the following
CGRect torpfr = torp.frame;
torpfr.origin.x = [[NSUserDefaults standardUserDefaults] floatForKey:@"torpx"];
torpfr.origin.y = [[NSUserDefaults standardUserDefaults] floatForKey:@"torpy"];
torp.frame = torpfr;
Basically this creates and positions the button based upon floats stored under torpx
and torpy
.
Essentially I have one object (torpfr
) at torpx
, torpy
, and I needg to draw a second object (let's assume label1
) offset to the Torpfr
.
Any help is much appreciated.
Solution
have a look here : https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CGGeometry/Reference/reference.html
you'ld find : CGRectOffset
A rectangle that is the same size as the source, but with its origin offset by dx units along the x-axis and dy units along the y-axis with respect to the source.
about animation, have a look here : iOS - Moving a UITextField to a Different Position when a UIView Moves