This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hide Legal link in the bottom left corner of Apple maps in iOS 6 | |
for (UIView *v in [self.map subviews]) { | |
NSLog(@"%@", NSStringFromClass([v class])); | |
if ([NSStringFromClass([v class]) isEqualToString:@"MKAttributionLabel"]) { | |
v.hidden = YES; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ## inserting. this can be done in viewDidLoad | |
// this can be any view, here I'm adding to main view | |
UIView *containerView = self.view; | |
// load child controller | |
UIViewController *svc = [[UIViewController alloc] initWithNibName:nil bundle:nil]; | |
// kill the randomness | |
svc.view.translatesAutoresizingMaskIntoConstraints = NO; | |
// add child VC to hierarchy | |
[self addChildViewController:svc]; | |
// set initial rect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)pulseView:(UIView *)view completion:(void (^)(void))block { | |
// if you use auto layout, view-based transform go haywire, as they trigger layoutSubviews | |
// consequence is that you have no idea where the view will end up on the screen once animation completes | |
// see this discussion: http://stackoverflow.com/questions/12943107/how-do-i-adjust-the-anchor-point-of-a-calayer-when-auto-layout-is-being-used | |
// thus (per solution 4 from link above), rewriting with CAKeyframeAnimation | |
CAKeyframeAnimation *ka = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; | |
ka.duration = .49; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// this subclass defines itemsSize as {320, 88} | |
MyUICollectionViewFlowLayout *l = [[MyUICollectionViewFlowLayout alloc] init]; | |
// initialize one subclass of UICollectionViewController | |
MainViewController *mvc = [[MainViewController alloc] initWithCollectionViewLayout:l]; | |
// initialize another with same layout | |
// but inside this init method do: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body, dt, dd { | |
font-family: "Avenir Next", sans-serif !important; | |
line-height: 1.5 !important; | |
} | |
body { | |
font-size: 14px !important; | |
font-weight: 400 !important; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIFontDescriptor *userFont = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleBody]; | |
float userFontSize = [userFont pointSize]; | |
someLabelOrText.font = [UIFont fontWithName:@"CustomFont" size:userFontSize]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)preferredContentSizeChanged:(NSNotification *)aNotification | |
{ | |
UITextView *textView = <the text view holding your attributed text> | |
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithAttributedString:textView.attributedText]; | |
NSRange range = NSMakeRange(0, attributedString.length - 1); | |
// Walk the string's attributes | |
[attributedString enumerateAttributesInRange:range options:NSAttributedStringEnumerationReverse usingBlock: | |
^(NSDictionary *attributes, NSRange range, BOOL *stop) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl https://developer.apple.com/videos/wwdc/2014/ | grep -iIoh 'http.*._hd_.*dl=1">HD' | sed -e 's/\?dl=1">HD//g' | xargs -n1 wget -N |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the version number from the tag in git and the number of commits as the build number | |
# | |
appVersion=$(git describe --long | cut -f 1 -d "-") | |
appBuild=$(git describe --long | cut -f 2 -d "-") | |
#gitHash=$(git describe --long | cut -f 3 -d "-") | |
echo "From GIT Version = $appVersion Build = $appBuild" | |
# | |
# Set the version info in plist file | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double ToRadians(double degrees) { return degrees * M_PI / 180; } | |
- (NSNumber *)geoDistanceFromLat:(CLLocationDegrees)lat1 fromLon:(CLLocationDegrees)lng1 toLat:(CLLocationDegrees)lat2 toLon:(CLLocationDegrees)lng2 { | |
CLLocationDistance EarthRadiusInMeters = 6367000.0; | |
CLLocationDistance distance = EarthRadiusInMeters * 2 * | |
asin(fmin(1, sqrt((pow(sin((ToRadians(lat2) - ToRadians(lat1)) / 2.0),2.0) | |
+ | |
cos(ToRadians(lat1)) * cos(ToRadians(lat2)) |
OlderNewer