Iphone 如何从固定的中心点旋转图像和箭头线

Iphone 如何从固定的中心点旋转图像和箭头线,iphone,xcode,image-rotation,icarousel,Iphone,Xcode,Image Rotation,Icarousel,在我的应用程序中,我有一个固定大小的按钮/中心点,我想旋转箭头线,当我触摸/向上/向下滚动时,此附加图像也会旋转。 我在这里做了一个演示,我使用icarousel类只滚动图像。 但我不能同时滚动箭头和图像。 请帮助我如何实现这一点。 我使用icarousel的唯一图像滚动代码在这里 - (UIView *)carousel:(__unused iCarousel *)carousel viewForItemAtIndex: (NSInteger)index reusingView:(UIV

在我的应用程序中,我有一个固定大小的按钮/中心点,我想旋转箭头线,当我触摸/向上/向下滚动时,此附加图像也会旋转。 我在这里做了一个演示,我使用icarousel类只滚动图像。 但我不能同时滚动箭头和图像。 请帮助我如何实现这一点。

我使用icarousel的唯一图像滚动代码在这里

  - (UIView *)carousel:(__unused iCarousel *)carousel viewForItemAtIndex: (NSInteger)index reusingView:(UIView *)view
{
UIView *viewFor;
UIImageView *itemView;
if (view==nil) {

    viewFor=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
    itemView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 45, 120, 120)];
    [itemView.layer setCornerRadius:itemView.frame.size.width/2];
    [itemView setClipsToBounds:YES];
    [viewFor addSubview:itemView];

        StikImage=[[UIImageView alloc]initWithFrame:CGRectMake(-140, 95, 140, 20)];
   StikImage.backgroundColor=[UIColor whiteColor];
   [viewFor addSubview:StikImage];

  }
  else
  {
    viewFor=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
    itemView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 45, 120, 120)];
    [itemView.layer setCornerRadius:itemView.frame.size.width/2];
    [itemView setClipsToBounds:YES];
    [viewFor addSubview:itemView];

        StikImage=[[UIImageView alloc]initWithFrame:CGRectMake(-140, 95, 140, 20)];
         StikImage.backgroundColor=[UIColor whiteColor];
        [viewFor addSubview:StikImage];

  }
   itemView.image=[images objectAtIndex:index];
return viewFor;
 }
这是我的自定义类型Microusel变换图像的方法

- (CATransform3D)carousel:(iCarousel *)carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform {

const CGFloat centerItemZoom = 1.6;
const CGFloat centerItemSpacing = 1.2;
const CGFloat centerItemYOffset = 100;
CGFloat spacing = [self carousel:carousel valueForOption:iCarouselOptionSpacing withDefault:1.3f];
CGFloat absClampedOffset = MIN(2.5, fabs(offset));
CGFloat clampedOffset = MIN(1.0, MAX(-1.0, offset));
CGFloat scaleFactor = 1.0 + absClampedOffset * (1.2/centerItemZoom - 1.0);
CGFloat yoffset = (1.0f - absClampedOffset) * centerItemYOffset;
offset = (scaleFactor * offset + scaleFactor * (centerItemSpacing - 1.0) * clampedOffset) * carousel.itemWidth * spacing;



if (carousel.vertical)
{
    transform = CATransform3DTranslate(transform, yoffset, offset, -absClampedOffset);

}
else
{
    transform = CATransform3DTranslate(transform, offset, yoffset, -absClampedOffset);
}

transform = CATransform3DScale(transform, scaleFactor, scaleFactor, 5.0f);
  return transform;
 }

使用以下代码旋转图像视图

imageview.transform = CGAffineTransformMakeRotation(degrees * M_PI/180);

您可以使用您想要的度数大小,如180、90、240、270…,这取决于您的要求“触摸/向上/向下滚动”

首先感谢您的回答@iSara,但我如何设置y偏移量和角度,以便针对图像向上/向下滚动箭头/线。@RAMA:您可以将上述代码与scrollview中的委托方法一起使用……我不能……我使用iCarousel view在我的代码中实现了此类型,仅适用于图像,但现在我想添加这些箭头/线,并附上图像..这些箭头同时旋转,图像角度相同..我如何实现这一点..请帮助我。。