Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)resizeImage:(UIImage *)i forView:(UIImageView *)v
- {
- CGSize iSize = i.size;
- CGSize vSize = v.frame.size;
- if ((iSize.height/vSize.height) > (iSize.width/vSize.width))
- {
- CGFloat ratio = vSize.height / iSize.height;
- [i drawInRect:CGRectMake(0, 0, i.size.width * ratio, i.size.height * ratio)];
- } else if ((iSize.width/vSize.width) > (iSize.height/vSize.height))
- {
- CGFloat ratio = vSize.width / iSize.width;
- [i drawInRect:CGRectMake(0, 0, i.size.width * ratio, i.size.height * ratio)];
- } else {
- CGFloat ratio = vSize.width / iSize.width;
- [i drawInRect:CGRectMake(0, 0, i.size.width * ratio, i.size.height * ratio)];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement