Make UIView Circle in Swift

I tried to deal with my problem, but it seems I did not find anything! Basically, I have a UIView that retrieves a Facebook Facebook photo after entering my application. This is a square at the moment, but I can’t understand how to turn a UIView into a circle ... Any help would be greatly appreciated, I'm still learning! For -Alex-

It just connects to a UIView ..

@IBOutlet var profilePictureView : FBProfilePictureView! 

This sets the view as an FB user profile profile

 profilePictureView.profileID = user.objectID 

And in the delegate.swift application

 FBProfilePictureView.self 

For all the code, I set the UIView class as FBProfilePictureView.

+8
facebook swift uiview circle
source share
2 answers

You can try this

  profilePictureView.layer.cornerRadius = profilePictureView.frame.size.width/2 profilePictureView.clipsToBounds = true profilePictureView.layer.borderColor = UIColor.whiteColor().CGColor profilePictureView.layer.borderWidth = 5.0 
+27
source share

Try defining the UIBezier path as a circle, and then add it as a clip to your view:

 let circle = UIBezierPath(arcCenter: (CGPoint), radius: (CGFloat), startAngle: 0, endAngle: 2*M_PI) 

double check, but I think arcCenter is in your coordinate system.

To add it as a clipping path, I think it is simple: (you will need to check the documents for details):

 circle.addClip() 
+1
source share

All Articles