自定义图像旋转?
Custom Image Rotation?
如何顺时针旋转这些图像?当他们加载时,出于某种原因他们站在他们一边。
//load the image
API* api = [API sharedInstance];//afnetworking call
int IdPhoto = [[data objectForKey:@"IdPhoto"] intValue];
NSURL* imageURL = [api urlForImageWithId:[NSNumber numberWithInt: IdPhoto] isThumb:YES];
AFImageRequestOperation* imageOperation = [AFImageRequestOperation imageRequestOperationWithRequest: [NSURLRequest requestWithURL:imageURL] success:^(UIImage *image) {
//create an image view, add it to the view
UIImageView* thumbView = [[UIImageView alloc] initWithImage: image];
thumbView.frame = CGRectMake(0,0,90,90);//thumbsize of image 180 is width and size 0 is spacing coordinates x,y
thumbView.contentMode = UIViewContentModeScaleAspectFit;
[self insertSubview: thumbView belowSubview: caption];
}];
NSOperationQueue* queue = [[NSOperationQueue alloc] init];
[queue addOperation:imageOperation];
}
return self;
}
@end
我想像这样旋转 imageView:
thumbView.transform=CGAffineTransformMakeRotation(M_PI*1.5); //or perhaps M_PI*0.5 for a quarter turn the other direction...
因为它更容易,所以改变图像本身的方向需要将其绘制到某处的上下文中以提取新的数据表示。
如何顺时针旋转这些图像?当他们加载时,出于某种原因他们站在他们一边。
//load the image
API* api = [API sharedInstance];//afnetworking call
int IdPhoto = [[data objectForKey:@"IdPhoto"] intValue];
NSURL* imageURL = [api urlForImageWithId:[NSNumber numberWithInt: IdPhoto] isThumb:YES];
AFImageRequestOperation* imageOperation = [AFImageRequestOperation imageRequestOperationWithRequest: [NSURLRequest requestWithURL:imageURL] success:^(UIImage *image) {
//create an image view, add it to the view
UIImageView* thumbView = [[UIImageView alloc] initWithImage: image];
thumbView.frame = CGRectMake(0,0,90,90);//thumbsize of image 180 is width and size 0 is spacing coordinates x,y
thumbView.contentMode = UIViewContentModeScaleAspectFit;
[self insertSubview: thumbView belowSubview: caption];
}];
NSOperationQueue* queue = [[NSOperationQueue alloc] init];
[queue addOperation:imageOperation];
}
return self;
}
@end
我想像这样旋转 imageView:
thumbView.transform=CGAffineTransformMakeRotation(M_PI*1.5); //or perhaps M_PI*0.5 for a quarter turn the other direction...
因为它更容易,所以改变图像本身的方向需要将其绘制到某处的上下文中以提取新的数据表示。