Skip to content

Instantly share code, notes, and snippets.

pod 'AFNetworking' # making requests
pod 'CocoaLumberjack' # logging
pod 'MagicalRecord' # coredata
pod 'FastttCamera' # taking pictures
pod 'WYPopoverController' # popover on iphone
pod 'FBSDKCoreKit' # facebook
pod 'FBSDKLoginKit' # facebook
pod 'FBSDKShareKit' # facebook
pod 'OAStackView' # UIStackView on iOS7
pod 'REMenu', :git => 'git@github.com:romaonthego/REMenu.git' # drop down menu
@christophercotton
christophercotton / CGRectAspectFit.m
Created November 20, 2015 14:51 — forked from lanephillips/CGRectAspectFit.m
Objective-C code to fit a CGRect inside or outside another CGRect while maintaining aspect ratio. The fitted rectangle is centered on the target rectangle.
CGFloat ScaleToAspectFitRectInRect(CGRect rfit, CGRect rtarget)
{
// first try to match width
CGFloat s = CGRectGetWidth(rtarget) / CGRectGetWidth(rfit);
// if we scale the height to make the widths equal, does it still fit?
if (CGRectGetHeight(rfit) * s <= CGRectGetHeight(rtarget)) {
return s;
}
// no, match height instead
return CGRectGetHeight(rtarget) / CGRectGetHeight(rfit);