gpt4 book ai didi

ios - 在 iOS Xcode 的 UIView 上移动图像

转载 作者:行者123 更新时间:2023-11-29 10:41:27 25 4
gpt4 key购买 nike

<分区>


- (void)viewDidLoad
{
// name of image
self.imageview.image = [UIImage imageNamed:@"Image.png"];
[self.view addSubview: self.imageview];
[super viewDidLoad];
}

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:touch.view];
self.imageview.center = touchLocation;
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
// get touch event
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.mytransperentview];
if ([touch view] == self.imageview)
{
self.imageview.center = touchLocation;
}
}

  1. 图像在移动,但不是自由移动。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com