相关疑难解决方法(0)

在CALayer中添加UIImage

我必须添加一个UIImageView作为MapView的子视图.为此,我在MapView上创建了一个图层.在这一层,我想放置我的图像,但我得到一个白色的矩形,没有别的.我的图片不可见.

这是代码:

- (void)viewDidLoad
{
    //......

    CALayer *layer = [CALayer layer];
    layer.backgroundColor = [[UIColor whiteColor] CGColor];

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        layer.bounds = CGRectMake(self.mapView.bounds.origin.x,
                                  self.mapView.bounds.origin.y, 80, 300);
    }
    else
    {
        layer.bounds = CGRectMake(self.mapView.frame.origin.x,
                                  self.mapView.frame.origin.y, 150, 700);
    }

    layer.contents = (id)[UIImage imageNamed:@"myImage.png"];
    //the name is correct but  in the output the image is not visible

    [[self.mapView layer] addSublayer:layer];
    [layer setNeedsDisplay];
}
Run Code Online (Sandbox Code Playgroud)

subview calayer uiimageview uiimage ios

40
推荐指数
3
解决办法
4万
查看次数

在UIImageView中的图像后面插入CAShapeLayer

正如标题所说。我有一个UIImageView,并且正在将CAShapeLayers插入到视图中。问题是我不知道如何将它们插入UIImageView的图像后面。任何建议将不胜感激,谢谢。

uiimageview uiimage cashapelayer swift swift3

2
推荐指数
1
解决办法
827
查看次数

标签 统计

uiimage ×2

uiimageview ×2

calayer ×1

cashapelayer ×1

ios ×1

subview ×1

swift ×1

swift3 ×1