IPhone - How to partially hide the preview?

I am developing one sample application using gestures where I can pinch, pan, and rotate. I have one main image width and height 300, and the beginning of x is 0 and y is 70. This is the image that I use from the interface constructor. After that, I add one label programmatically in the middle of the imageView. After adding the label, I can pinch, pinch and rotate the label to look. Now the actual requirement is that when I drag the label out of the image, I have to display a partial label, for example (the text of my label is ABCDXYZ). Once I dragged Z outside of Z, you should be invisible, the other part of ABCDXY should be visible. More clear is dragging one view into another view. How can i achieve this.

+4
source share
2 answers

What you need to do is create a UIView . On this add a UIImageView, e.g.

 [View addSubView:ImageView]; 

then add UIlabel to UIImageView e.g.

 [ImageView addSubView:Label]; 

Now set clipsToBounds = YES . I think now your problem with a partial label will be solved, since the label will move inside the UIView , and as soon as it disappears, this will be partially shown. Any doubts, please tell. Thanx :)

+2
source

It’s really difficult to use a pocket-sized solution for this; instead, it may be an offer. I assume that your UILabel text is dynamic, some scripts can be used for this.

1) When you touch your label inside a UIImageView , you will get the exact coordinates .

2) Get the position in which the user touches UILabel .

3) Compare the coordinates of the touch with the full coordinates of UILabel .

4) Suppose what character is touched. (You must check it, the size of the text may also matter).

5) When the user drags that particular character (say Z ), you need to remove it from the UILabel text.

It's all. Everything is ready.

0
source

Source: https://habr.com/ru/post/1438333/


All Articles