【问题标题】:stacking multiple images with transparency one above another on iPhone iOS在 iPhone iOS 上堆叠多个透明图像
【发布时间】:2012-06-15 12:27:19
【问题描述】:

我正在编写一个指南针,它应该根据CLLocation 课程旋转指南针图像。

在该指南针的顶部,我想显示一个箭头,该箭头应指向与指南针不同的方向。为了实现这一点,我认为我可以将多个图像一个接一个地堆叠并让它们独立旋转。 箭头图像应该是透明的。

如何堆叠这些图像并独立旋转它们?

【问题讨论】:

    标签: iphone ios xcode uiimageview


    【解决方案1】:

    将每张图片放在自己的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);
    

    【讨论】:

    • M_PI、M_PI_2 等比四舍五入、手动输入的 pi 近似值更好用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多