如何在iPhone中创建电话拨号器效果?
我想创建电话拨号器效果,那么我如何才能实现这种效果呢?。有任何API可用于此目的吗?我已经设置了图像在图像视图中,图像是圆形的。现在我想触摸并拖动图像,如果我拖动单个图像,它会将所有图像移动到特定路径。请看我的屏幕截图 请帮帮我 谢谢如何在iPhone中创建电话拨号器效果?,iphone,core-animation,Iphone,Core Animation,我想创建电话拨号器效果,那么我如何才能实现这种效果呢?。有任何API可用于此目的吗?我已经设置了图像在图像视图中,图像是圆形的。现在我想触摸并拖动图像,如果我拖动单个图像,它会将所有图像移动到特定路径。请看我的屏幕截图 请帮帮我 谢谢 创建视图(视图a)并将背景色设置为透明 将图像视图添加为子视图以查看 在视图A中重写以下方法: - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { // Only return YES
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
// Only return YES if the touch is in one of the subviews
// - we dont care about touches that are just in this view
for (UIView* view in self.subviews) {
// We need to convert the point into the recievers co-ordinate system
// (as per the documentation on 'pointInside:withEvent')
CGPoint convertedPoint = [self convertPoint:point toView:view];
if ([view pointInside:convertedPoint withEvent:event]) {
return YES;
}
}
return NO;
}
您可以使用UIPangestureRecognitor检测父图像视图上的平移/拖动。然后应用CGAffineTransform,根据用户的手指位置旋转该视图
// Calculate the rotation you want
CGFloat radians = degreesToRadians(position*totalRotation);
[dialerView setTransform:CGAffineTransformMakeRotation(radians)];
您需要了解如何计算位置和总旋转。旋转电话拨号器api?现在人们期望太高了看看真正的电话。它们不会沿着路径移动孔。他们转动一个有孔的圆盘。我会尝试将所有图像放在一个视图中,并旋转该视图。