Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone ui拖动ui按钮时查看更改帧_Iphone_Ios_Uiimageview_Rotation_Frame - Fatal编程技术网

Iphone ui拖动ui按钮时查看更改帧

Iphone ui拖动ui按钮时查看更改帧,iphone,ios,uiimageview,rotation,frame,Iphone,Ios,Uiimageview,Rotation,Frame,我有问题。我有ui图像视图和ui按钮 当我移动ui按钮时,如箭头所示,我需要更改按钮的帧ui图像视图。当我将ui按钮拖动到顶部时,我需要旋转ui图像视图 我想我需要在UIButton中添加手势。但是,当我拖动ui按钮时,如何计算UIImageView的新帧呢 多谢各位 @synthesize resizableImageView; @synthesize resizeButton; - (void)viewDidLoad { [super viewDidLoad]; // Do

我有问题。我有
ui图像视图
ui按钮

当我移动
ui按钮时,如箭头所示,我需要更改按钮的帧
ui图像视图
。当我将
ui按钮
拖动到顶部时,我需要旋转
ui图像视图

我想我需要在UIButton中添加手势。但是,当我拖动
ui按钮时,如何计算
UIImageView
的新帧呢

多谢各位

@synthesize resizableImageView;
@synthesize resizeButton;
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [resizeButton addTarget:self action:@selector(startDraggableCorner) forControlEvents:UIControlEventTouchDown];
    [resizeButton addTarget:self action:@selector(stopDraggableCorner) forControlEvents:UIControlEventTouchUpInside];
}
-(void)startDraggableCorner
{
    gestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(wasDragged:)];
    [[self view] addGestureRecognizer:gestureRecognizer];
}
-(void)wasDragged:(UIPanGestureRecognizer*)gesture
{
    CGRect imageFrame = [resizableImageView frame];
    imageFrame.size.height = [[gesture valueForKey:@"_lastScreenLocation"] CGPointValue].y - imageFrame.origin.y;
    imageFrame.size.width = [[gesture valueForKey:@"_lastScreenLocation"] CGPointValue].x - imageFrame.origin.x;
    [resizableImageView setFrame: imageFrame];
    CGRect buttonFrame = [resizeButton frame];
    buttonFrame.origin.x = [[gesture valueForKey:@"_lastScreenLocation"] CGPointValue].x;
    buttonFrame.origin.y = [[gesture valueForKey:@"_lastScreenLocation"] CGPointValue].y;
    [resizeButton setFrame:buttonFrame];

}
-(void)stopDraggableCorner
{
    [[self view] removeGestureRecognizer:gestureRecognizer];
}
这(几乎)成功地实现了您可调整大小的行为。旋转图像,也许您可以检查
[[signature valueForKey:@“\u lastScreenLocation”]CGPointValue].y
是否低于某个值,然后调用方法旋转图像