UIView.layer的基本属性

Posted on 2013-04-03 16:02  逍_遥  阅读(125)  评论(0)    收藏  举报

    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"apple.jpg"]];

    imageView.frame = CGRectMake(85.0, 100.0, 150.0, 148.0);

    [self.view addSubview:imageView];

    

    // UIView对应的CALayer对象

   CALayer *imageLayer = imageView.layer;

    //NSLog(@"%@", imageView.layer);

    

    // 改变CALayer的属性,看看有什么效果

    //imageLayer.position = CGPointMake(160.0, 324.0);

    //imageLayer.opacity = 0.5;

    

    // CALayer设置边框属性

    imageLayer.borderWidth = 5.0;

    imageLayer.borderColor = [[UIColor blackColor] CGColor];

    imageLayer.cornerRadius = 30.0;

    

    // CALayer设置阴影属性

    imageLayer.shadowOpacity = 0.8;

    imageLayer.shadowOffset = CGSizeMake(10.0, 10.0);

    imageLayer.shadowColor = [[UIColor blackColor] CGColor];

//    imageLayer.shadowRadius = 30.0;/Users/ibokan/Downloads/2.png

 

 

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3