Create a new item, and then put a view in the storyboard and set the view position in AutoLayout
And the top of the distance (set Y)
Distance from left (set X)
Set size
Drag a port for view
Add a drag gesture to the view in Viewdidload
-(void) viewdidload {
[super viewdidload];
Add drag gesture
uipangesturerecognizer *pan = [[Uipangesturerecognizer alloc] initwithtarget:self action: @selector (Handlepan:)];
[Self.springbackview Addgesturerecognizer:pan];
Do no additional setup after loading the view, typically from a nib.
}
Next, implement Handlepan:
-(void) Handlepan: (uipangesturerecognizer*) recognizer{
cgpoint translation = [recognizer Translationinview: Self.view];
Recognizer.view.center = Cgpointmake (recognizer.view.center.x + translation.x,
recognizer.view.center.y + TRANSLATION.Y);
[Recognizer Settranslation:cgpointzero InView:self.view];
if (recognizer.state = = uigesturerecognizerstateended) {
[UIView animatewithduration:0.3 delay:0 usingspringwithdamping:0.5 initialspringvelocity:10 options:0 animations:^{
[Self.springbackview Layoutifneeded];
} Completion:nil];
}
OK, now run your program to drag the view ...