Skip to main content

Posts

Showing posts with the label resize

Resize any view

https://github.com/spoletto/SPUserResizableView HOW TO USE:      CGRect imageFrame = CGRectMake ( 50 , 200 , 100 , 80 );     SPUserResizableView *imageResizableView = [[ SPUserResizableView alloc ] initWithFrame :imageFrame];     CustomView *otherViewObj = [[ CustomView alloc ] initWithFrame :gripFrame];     imageResizableView. contentView = otherViewObj; // ADD ANY VIEW LIKE UIIMAGEVIEW ETC.     imageResizableView. delegate = self ;     [ self . view addSubview :imageResizableView]; SPUserResizableView .h // // SPUserResizableView.h // SPUserResizableView // // Created by Stephen Poletto on 12/10/11. // // SPUserResizableView is a user-resizable, user-repositionable // UIView subclass. #import typedef struct SPUserResizableViewAnchorPoint { CGFloat adjustsX; CGFloat adjustsY; CGFloat adjustsH; CGFloat adjustsW; } SPUserResizableViewAnchorPoint; @protocol SP...

Resize Image Frame

Get the image frame size as per the image size ratio : -( CGRect )imagePosition:( int )imgWidth forImageHeight:( int )imgHeight maxFrame:( CGRect ) rect { float xPos=rect. origin . x , yPos=rect. origin . y ; int maxWidth=rect. size . width ; int maxHeight=rect. size . height ; float imgCWidth=imgWidth; float imgCHeight=imgHeight; float ratio= 0 ; if (imgCHeight> 0 ) ratio=( float )imgCHeight/( float )imgCWidth; if (imgCWidth>imgCHeight) { if (imgCWidth>maxWidth) { imgCWidth=maxWidth; imgCHeight=imgCWidth*ratio; } if (imgCHeight>maxHeight) { imgCHeight=maxHeight; imgCWidth=imgCHeight/ratio; } } else { if (imgCHeight>maxHeight) { imgCHeight=maxHeight; imgCWidth=imgCHeight/ratio; } if (imgCWidth>maxWidth) { imgCWidth=maxWidth; imgCHeight=imgCWidth*ratio; } } maxWidth=imgCWidth; maxHeight=imgCHeigh...