I'm trying to making a FBSDKProfilePictureView rounded but I can't.
This what I have:
ViewController.h
@property (weak, nonatomic) IBOutlet FBSDKProfilePictureView *fbPhoto;
ViewController.m on ViewDidLoad
self.fbPhoto.layer.cornerRadius = 30.0;
self.fbPhoto.layer.borderColor = [UIColor lightGrayColor].CGColor;
self.fbPhoto.layer.borderWidth = 1.0;
It makes a round circle in front of the UIIMage but it doesn't "crop" the image.
How can i do it
just set clipsToBounds
self.fbPhoto.layer.cornerRadius = 30.0;
self.fbPhoto.clipsToBounds=YES;
self.fbPhoto.layer.borderColor = [UIColor lightGrayColor].CGColor;
self.fbPhoto.layer.borderWidth = 1.0;
First of all for set rounded profile picture like whats up and FB, you can use below logic for that and after set setAutoresizesSubviews
to NO
of fbPhoto class.
use below code instead of your..
[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];
Jay's suggestion works. Here it is in swift:
//rounded corners
ProfilePicture.layer.cornerRadius = ProfilePicture.frame.size.width / 2
ProfilePicture.layer.borderColor = UIColor.whiteColor().CGColor
ProfilePicture.layer.borderWidth = 1.0;
ProfilePicture.clipsToBounds = true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.