xcode 在 iphone 中预览圆形图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2448725/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Preview rounded image in iphone
提问by camilo
can anyone tell me how can I create an image preview inside a customized cell with the aspect of the ones loaded in the mms'.
谁能告诉我如何在自定义单元格中创建图像预览,其中包含加载在 mms 中的图像的外观。
I've been trying to do it by changing values in IB and I haven't been able to.
我一直在尝试通过更改 IB 中的值来做到这一点,但我没能做到。
Thanks a lot!
非常感谢!
(source: iphonehelp.in)
(来源:iphonehelp.in)
Thanks for the three answers.
谢谢三位的回答。
Doing
正在做
cell3.imageView.layer.masksToBounds = YES;
cell3.imageView.layer.cornerRadius = 16;
cell3.imageView.layer.borderColor = [UIColor lightGrayColor].CGColor;
cell3.imageView.layer.borderWidth = 1.0;
I was able to do part of what I want. However, I still can't put that "glow" look on the image. Does anybody now which property should I control?
我能够做我想做的一部分。但是,我仍然无法在图像上添加“发光”外观。现在有人应该控制哪些财产?
Thanks a lot (and thanks again).
非常感谢(再次感谢)。
回答by Noah Witherspoon
Sure. Add the QuartzCore framework to your project, then:
当然。将 QuartzCore 框架添加到您的项目中,然后:
#import <QuartzCore/QuartzCore.h>
// ...
cell.imageView.layer.masksToBounds = YES;
cell.imageView.layer.cornerRadius = 4;
Note that the cornerRadius
property is only available in OS 3.0 and later; if you're supporting an older version (which you probably don't have to be), you'll need to do some Core Graphics work.
请注意,该cornerRadius
属性仅在 OS 3.0 及更高版本中可用;如果您支持旧版本(您可能不必如此),则需要做一些 Core Graphics 工作。
回答by Bryan Clark
will creating an image in an image editor and then setting it as the cell's background not work?
在图像编辑器中创建图像然后将其设置为单元格的背景不起作用吗?
This might be useful for you http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
这可能对你有用 http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
回答by Ole Begemann
If your image is in an image view and you're targeting OS 3.0+, you can set imageView.layer.cornerRadius
.
如果您的图像在图像视图中并且您的目标是 OS 3.0+,则可以设置imageView.layer.cornerRadius
.