【问题标题】:How do I create a white border and black shadow for my UIImageView?如何为我的 UIImageView 创建白色边框和黑色阴影?
【发布时间】:2011-05-26 03:07:34
【问题描述】:

如何为我的 UIImageView 创建白色边框和黑色阴影?

【问题讨论】:

    标签: ios cocoa-touch uiimageview


    【解决方案1】:

    只导入

    #import  <QuartzCore/QuartzCore.h> 
    

    并确保您已将 QuartzCore 框架添加到您的项目中。

    然后添加边框

    [imageView.layer setBorderColor: [[UIColor whiteColor] CGColor]];
    [imageView.layer setBorderWidth: 2.0];
    

    要创建阴影,请参阅this SO 问题,这将使您继续前进..

    【讨论】:

    • 只需确保导入 并确保已将 QuartzCore 框架添加到您的项目中。
    • 这才是使用quartz核心框架添加边框的正确方式....+1给你...
    • 是的@Rexeisen,忘记了包含和框架..感谢您指出..将编辑我的答案..
    • 好的。之后我的问题是,如何访问越狱iphone根目录。我的主题是设置每个月的壁纸。并从数据库中获取该壁纸。分配并存储到数据库完成。但是如何访问越狱iphone。请给我正确的方向来做这个。请
    【解决方案2】:

    这是我在 UIImageView 中为 UIImage 添加边框和阴影的方式

    someImageView.image = someUIImage;
    someImageView.frame = CGRectMake(45, 25, 50, 50);
    [someImageView.layer setBorderColor: [[UIColor whiteColor] CGColor]];
    [someImageView.layer setBorderWidth: 2.0];
    [someImageView.layer setShadowOffset:CGSizeMake(-3.0, 3.0)];
    [someImageView.layer setShadowRadius:3.0];
    [someImageView.layer setShadowOpacity:1.0];
    

    记住:

    #import  <QuartzCore/QuartzCore.h>
    

    【讨论】:

    • 另外记得设置 someImageView.clipsToBounds = NO.
    【解决方案3】:

    您可以将它作为另一个 UIImageView 添加到显示您的图像的后面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多