2015-05-09 49 views
0

我想使FBSDKProfilePictureView圓形,但我不能。如何製作iOS FBSDKProfilePictureView?

這是我有:

ViewController.h

@property (weak, nonatomic) IBOutlet FBSDKProfilePictureView *fbPhoto; 

ViewController.m的viewDidLoad中

self.fbPhoto.layer.cornerRadius = 30.0; 
self.fbPhoto.layer.borderColor = [UIColor lightGrayColor].CGColor; 
self.fbPhoto.layer.borderWidth = 1.0; 

它使一個圓圈中的UIImage的前面,但它不「裁剪」圖像。

我該怎麼辦呢

+0

試試這個self.fbPhoto.layer.clipToBounds = YES;或self.fbPhoto.layer.maskToBounds = YES; –

回答

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; 
+0

它的工作原理!非常感謝! – titolancreo

0

首先對集圓潤資料圖片喜歡怎麼了和FB,可以在下面的邏輯使用的是和集setAutoresizesSubviewsNO fbPhoto類。

下面的代碼,而不是你使用..

[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]; 
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