vendredi 14 novembre 2014

iOS: Dynamically change UILabel Alignment based on View position


Vote count:

0




I have a UIView which contains a smaller UIView. Inside the smaller UIView is 2 labels, one above the other.


The widths of these labels varies depending on what the user enters. Then the smaller UIView is adjusted accordingly.


The user has the ability to move the smaller UIView around the screen using Pan Gesture.


I'm struggling to work out how to dynamically change the UILabel Alignment based on the smaller UIView's position in the main view.


Say for example my main UIView is 1,000 pixels and the smaller UIView is 400 pixels. How do I work out if they drag it to the middle?


I'm thinking I should minus the 400 from the 1,000 which would give me 600 pixels, then split this into thirds (Left Align, Center Align & Right Align) and finally check if the centre of smaller UIView is inside one of these bands but I can't seem to get it to work.


Could someone offer some advice on how to set this up? I need it dynamically because users can either use iPhone / iPad / Portrait / Landscape etc.


Hope this is clear.



asked 1 min ago







iOS: Dynamically change UILabel Alignment based on View position

Aucun commentaire:

Enregistrer un commentaire