Я создаю UIImageview при нажатии кнопки.Как переместить конкретный UIImageview в начало?
Это мой код:
_imgfull.userInteractionEnabled=YES;
_imgfull.clipsToBounds = YES;
//this all for image positioned
imgpositioned=[[UIImageView alloc]initWithFrame:CGRectMake(0,0,500,500)];
imgpositioned.userInteractionEnabled=YES;
imgpositioned.tag=tag;
tag++;
if(tag==1)
{
imgpositioned.backgroundColor =[UIColor redColor];
}
else
{
imgpositioned.backgroundColor =[UIColor greenColor];
}
//pinch gesture
UIPinchGestureRecognizer *pinch=[[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(Pinchforimage:)];
pinch.delegate=self;
[imgpositioned addGestureRecognizer:pinch];
// create and configure the rotation gesture
UIRotationGestureRecognizer *rotationGestureRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationGestureDetected:)];
[rotationGestureRecognizer setDelegate:self];
[imgpositioned addGestureRecognizer:rotationGestureRecognizer];
// pan gesture
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureDetected:)];
[panGestureRecognizer setDelegate:self];
[imgpositioned addGestureRecognizer:panGestureRecognizer];
//long press gesture
UILongPressGestureRecognizer *longpress=[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longpress:)];
[longpress setDelegate:self];
[imgpositioned addGestureRecognizer:longpress];
[_imgfull addSubview:imgpositioned];
Это мой длинный пресс метод жест
[![-(void)longpress:(UILongPressGestureRecognizer *)longg
{
NSLog(@"gesture recogniser long press obtained ==%d",\[longg.view tag\]);
UIGestureRecognizerState state =\[longg state\];
if(state ==UIGestureRecognizerStateBegan ||state ==UIGestureRecognizerStateChanged)
{
\[imgpositioned superview\];
}
}
Когда пользователь долго нажмите UIImageView я хочу, чтобы переместить UIImageview выше, например, если пользователь долго нажимает красную UIIma geview он должен прийти над зеленым ImageView :)
возможно помочь мне друзья:
использовать это - https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/#//apple_ref/occ/instm/UIView/bringSubviewToFront: – Skywalker