我试图将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前面做了一个圆圈,但它没有"裁剪"图像。
我该怎么做
答案 0 :(得分:3)
只需设置clipsToBounds
self.fbPhoto.layer.cornerRadius = 30.0;
self.fbPhoto.clipsToBounds=YES;
self.fbPhoto.layer.borderColor = [UIColor lightGrayColor].CGColor;
self.fbPhoto.layer.borderWidth = 1.0;
答案 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];
答案 2 :(得分:0)
//rounded corners
ProfilePicture.layer.cornerRadius = ProfilePicture.frame.size.width / 2
ProfilePicture.layer.borderColor = UIColor.whiteColor().CGColor
ProfilePicture.layer.borderWidth = 1.0;
ProfilePicture.clipsToBounds = true