【问题标题】:set UIView's Content to CAlyer's Contents in iphone在 iphone 中将 UIView 的内容设置为 CAlyer 的内容
【发布时间】:2013-11-22 07:08:01
【问题描述】:

我正在尝试将视图的内容添加到 LAyer 的内容中,可以吗?

v1=[[UIView alloc]initWithFrame:CGRectMake(10, 10, 30, 30)];
        v1.backgroundColor=[UIColor redColor];
        UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(05, 05, 20, 20)];
        lbl.text=@"ABC";
        [v1 addSubview:lbl];

       CALayer *iconImageLayer = [[CALayer alloc] init];
    iconImageLayer.contents=?????? //Try to add view

帮我解决这个问题

谢谢,

【问题讨论】:

    标签: ios iphone objective-c uiview calayer


    【解决方案1】:

    使用UIViewlayer 属性。

    CALayer *iconImageLayer = v1.layer

    或者只是简单地使用v1.layer,只要你会使用iconImageLayer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-12
      • 2012-06-10
      • 1970-01-01
      相关资源
      最近更新 更多