Жест вращения, изменяющий вид - PullRequest
0 голосов
/ 27 сентября 2019

Чего я хочу добиться: я хочу создать копию выбранного представления.Думаю, у меня есть два UIImageView на вид.Я выбираю оба вида и хочу клонировать оба вида.

Все работает нормально, пока я не поворачиваю UIImageView.Если я вращаю представление, UIImageView меняет свой кадр.

UIView *viewClone = [[UIView alloc]initWithFrame:CGRectMake(fltLeadingMin, fltTopMin, fltCloneViewWidth, fltCloneViewHeight)];
viewClone.backgroundColor = [UIColor redColor];

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)];
[viewClone addGestureRecognizer:panGesture];

for (UIImageView *imgView in arrSelectedViews) {
    //UIImageView *imgViewClone = (UIImageView*)[imgView snapshotViewAfterScreenUpdates:true];

    NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject:imgView];
    UIImageView *imgViewClone = [NSKeyedUnarchiver unarchiveObjectWithData:archivedData];



    imgViewClone.frame = CGRectMake(imgViewClone.frame.origin.x - viewClone.frame.origin.x, imgViewClone.frame.origin.y - viewClone.frame.origin.y, imgView.frame.size.width, imgView.frame.size.height);
    imgViewClone.backgroundColor = UIColor.blueColor;



    [viewClone addSubview:imgViewClone];
}

https://i.stack.imgur.com/Haz6B.png

...