-(void)themBtnClick//访问相册的按钮的方法
{
UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
pickerImage.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
//pickerImage.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
pickerImage.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:pickerImage.sourceType];
}
pickerImage.delegate = self;
pickerImage.allowsEditing = YES;
[self presentViewController:pickerImage animated:YES completion:nil];
}
/*-----------------------------UIImagePickerController的代理方法------------------------------------*/
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
UIImage *image=[info objectForKey:UIImagePickerControllerEditedImage];
UIImage *theImage = [self imageWithImageSimple:image scaledToSize:CGSizeMake(250.0, 167.0)];
// _themeImg.image = theImage;
_themeImg.image = theImage;
[self dismissViewControllerAnimated:YES completion:^{
}];
}
- (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize
{//
// Create a graphics image context
UIGraphicsBeginImageContext(newSize);
// Tell the old image to draw in this new context, with the desired
// new size
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
// Get the new image from the context
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
// End the context
UIGraphicsEndImageContext();
// Return the new image.
return newImage;
}