[英]How to make iOS FBSDKProfilePictureView Round?
我正在尝试使FBSDKProfilePictureView取整,但我不能。
这是我所拥有的:
ViewController.h
@property (weak, nonatomic) IBOutlet FBSDKProfilePictureView *fbPhoto;
ViewDidLoad上的ViewController.m
self.fbPhoto.layer.cornerRadius = 30.0;
self.fbPhoto.layer.borderColor = [UIColor lightGrayColor].CGColor;
self.fbPhoto.layer.borderWidth = 1.0;
它在UIIMage前面制作了一个圆形圆圈,但没有“裁剪”图像。
我该怎么做
只需设置clipsToBounds
self.fbPhoto.layer.cornerRadius = 30.0;
self.fbPhoto.clipsToBounds=YES;
self.fbPhoto.layer.borderColor = [UIColor lightGrayColor].CGColor;
self.fbPhoto.layer.borderWidth = 1.0;
首先,要设置舍入的个人资料图片(如whats up和FB),可以为此使用以下逻辑,并将setAutoresizesSubviews
设置为fbPhoto类的NO
之后。
使用以下代码代替您的代码。
[self.fbPhoto.layer setCornerRadius:self.fbPhoto.frame.size.height/2];
[self.fbPhoto.layer setBorderColor:[UIColor lightGrayColor].CGColor];
[self. fbPhoto.layer setBorderWidth:1];
[self.fbPhoto setAutoresizesSubviews:NO];
周杰伦的建议行之有效。 这是迅速的:
//rounded corners
ProfilePicture.layer.cornerRadius = ProfilePicture.frame.size.width / 2
ProfilePicture.layer.borderColor = UIColor.whiteColor().CGColor
ProfilePicture.layer.borderWidth = 1.0;
ProfilePicture.clipsToBounds = true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.