Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Circle crop image

Can i add something so the user can crop a circle image instead beacuse the image I'm displaying on profile is a circle?

´´´

  • (void)showPhotoLibary { if (([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)) { return; }

    UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
    mediaUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    
    // Displays saved pictures from the Camera Roll album.
    mediaUI.mediaTypes = @[(NSString*)kUTTypeImage];
    
    // Hides the controls for moving & scaling pictures
    mediaUI.allowsEditing = YES;
    
    mediaUI.delegate = self;
    
    //  [self.navigationController presentModalViewController: mediaUI animated: YES];
    
    [self presentViewController:mediaUI animated:YES completion:nil];
    

    }

´´´

1 Answer

Brett Doffing
Brett Doffing
4,978 Points

I would probably look into masking the image with a circle (which you may already be doing for the profile), or creating a circle to move around the image, whereby once the circle is placed, the coordinates for the center of the circle could be used in relation to the original image.