gpt4 book ai didi

iphone - 圆角 UIView 或 UIImageView

转载 作者:行者123 更新时间:2023-12-03 18:34:35 25 4
gpt4 key购买 nike

我需要向 UIImageView 添加圆角。我从论坛找到了解决方案,并尝试了以下代码;

UIImageView * roundedView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"wood.jpg"]];
// Get the Layer of any view
CALayer * l = [roundedView layer];
[l setMasksToBounds:YES];
[l setCornerRadius:10.0];

我使用的是 iOS 5,并且找不到 setMasksToBounds:YESsetCornerRadius

那么有没有其他方法可以在我的 UIImageview 中获得圆角?

最佳答案

要在UIView(或其子类UIImageView)上制作圆角,您需要像您在问题中所写的那样,在图层上设置cornerRadius。例如:

theRoundedCornersView.layer.cornerRadius = 10.0f;

导入正确的 header ,它将编译:

#import <QuartzCore/QuartzCore.h>

不要忘记将其添加到您的框架中来链接它。

关于iphone - 圆角 UIView 或 UIImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8669553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com