拖动对象时屏幕上的对象开始闪烁

发布于 2024-11-02 21:29:52 字数 615 浏览 7 评论 0原文

我有一个用户可以在我的应用程序中在屏幕上拖动的对象。但由于某种原因,当他们开始将其拖动到另一个 UIView 上时,屏幕上的项目开始闪烁。所以CAGradientLayer的一部分会出现在其他所有东西的前面,有些东西似乎会把自己推到后面,各种奇怪的活动。不幸的是,我无法截取此内容的屏幕截图。这是我一直用来拖动的代码。

NSSet *touches = [event touchesForView:sender];
    UITouch *myTouch = [touches anyObject];
    CGPoint startPoint = [myTouch locationInView:self.view];
    positionX = startPoint.x;
    positionY = startPoint.y;   

        colourDropView.center = CGPointMake(positionX-15, positionY-25);

正如您可能猜到的那样,colourDropView 是被拖动的对象。当最后一行被实现时,它开始闪烁,并且每次用户移动手指时都会发生。当他们拖动手指时,没有其他代码在运行,只有上面的代码在运行。

关于为什么会发生这种情况有什么想法吗?

I have an object that the user can drag around the screen in my app. But for some reason, when they start to drag it over another UIView, the items on screen start blinking. So part of the CAGradientLayer will appear in front of everything else, some things will seem to push themselves to the back, all sorts of bizarre activity. I haven't been able to take a screenshot of this unfortunately. This is the code that i've been using to drag the dragging.

NSSet *touches = [event touchesForView:sender];
    UITouch *myTouch = [touches anyObject];
    CGPoint startPoint = [myTouch locationInView:self.view];
    positionX = startPoint.x;
    positionY = startPoint.y;   

        colourDropView.center = CGPointMake(positionX-15, positionY-25);

colourDropView is the object that's being dragged, as you might guess. And it's when that last line is implemented when it starts the blinking, and it happens each time the user moves their finger. No other code is running when they drag their finger, only what is above.

Any ideas as to why this may be happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

非要怀念 2024-11-09 21:29:52

事实证明这是一个错误。 colorDropView 有圆角,并将“maskstobounds”设置为 YES。由于某种原因,当将此视图拖到 CAGradientLayer 上时,这会导致 CAGradientLayer 崩溃。

Turns out it's a bug. colourDropView had rounded corners, and had 'maskstobounds' set to YES. For some reason this causes a CAGradientLayer to freak out when this view is dragged over it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文