我知道这是一个常见的问题,但我是堆栈来实现它。我有一个权重和高度相等的imageview。当我从媒体库中选择一个图像时,一些图像适合圆形但有些图像不适合圆形图像视图。
任何人都可以建议我如何将任何类型的图像集设置为圆形图像视图吗?
因为我想要实现用户可以设置他/她的个人资料图片。所以用户插入任何类型的图像或任何分辨率,我需要裁剪该图像,但我无法做到这一点。而且我也不喜欢任何第三个图书馆。
这是我的代码:
-(void)btnImgAct //Button Action
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypePhotoLibrary])
{
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentViewController:imagePickerController animated:YES completion:nil];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)Info
{
UIImage *pickerImage=[[UIImage alloc]init];
pickerImage=image;
imageDataPicker =[[NSData alloc] init];
imageDataPicker = UIImageJPEGRepresentation(pickerImage, 0.1); //For resize
if([imageDataPicker length]<2097152) //bytes 1048576
{
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
[self dismissViewControllerAnimated:YES completion:nil];
picker=nil;
[self SubmitImage1:pickerImage];
}
-(void)SubmitImage1:(UIImage *)image
{
EditProfileImage.image=image; //insert image into imageview
//Create circle imageview
EditProfileImage.layer.cornerRadius = EditProfileImage.frame.size.width / 2;
[EditProfileImage setContentMode:UIViewContentModeScaleAspectFit];
EditProfileImage.layer.masksToBounds = YES;
EditProfileImage.layer.borderWidth = 3.0f;
EditProfileImage.layer.borderColor = [UIColor blackColor].CGColor;
}
答案 0 :(得分:0)
删除了一些不必要的行并更改了图像视图以对生成的图像执行纵横填充。我测试了这个,它适用于我尝试的任何图像。
<VirtualHost *:80>
ServerName pastebin.mydomain.com
ServerAlias www.pastebin.mydomain.com
DocumentRoot /var/www/pastebinjs/
Options -Indexes
ErrorDocument 503 /maintenance.html
ProxyRequests on
ProxyPass /maintenance.html !
ProxyPass / http://localhost:8000/
</VirtualHost>