【发布时间】:2012-06-15 12:27:19
【问题描述】:
我正在编写一个指南针,它应该根据CLLocation 课程旋转指南针图像。
在该指南针的顶部,我想显示一个箭头,该箭头应指向与指南针不同的方向。为了实现这一点,我认为我可以将多个图像一个接一个地堆叠并让它们独立旋转。 箭头图像应该是透明的。
如何堆叠这些图像并独立旋转它们?
【问题讨论】:
标签: iphone ios xcode uiimageview
我正在编写一个指南针,它应该根据CLLocation 课程旋转指南针图像。
在该指南针的顶部,我想显示一个箭头,该箭头应指向与指南针不同的方向。为了实现这一点,我认为我可以将多个图像一个接一个地堆叠并让它们独立旋转。 箭头图像应该是透明的。
如何堆叠这些图像并独立旋转它们?
【问题讨论】:
标签: iphone ios xcode uiimageview
将每张图片放在自己的UIImageView 中,然后在此UIImageView 上添加 alpha
例如,
UIImageView *arrow1 = [[UIImageView alloc] init];
arrow1.frame = self.ArrowContainerView.bounds;
[self.ArrowContainerView addSubView:arrow1];
//Add alpha
arrow1.alpha = .7;
//adding another arrow
UIImageView *arro21 = [[UIImageView alloc] init];
arrow2.frame = self.ArrowContainerView.bounds;
[self.ArrowContainerView addSubView:arrow2];
//Add alpha
arrow2.alpha = .7;
//Rotating arrow 1
arrow1.transform = CGAffineTransformMakeRotation(-1.142);
//Rotating arrow 2
arrow2.transform = CGAffineTransformMakeRotation(-3.142);
【讨论】: