Skip to content

Instantly share code, notes, and snippets.

@ShadoFlameX
ShadoFlameX / custom_callouts.md
Last active May 20, 2018 14:14
Custom Map Annotation Callouts on iOS
  1. Create a UIView subclass for the pin callout view.
  2. Create a subclass of MKAnnotationView for your map pins.
  3. Add an instance of the callout view subclass to your MKAnnotationView subclass.
  4. Add a property to toggle the callout view to your MKAnnotationView subclass. This example fades in/out:
    - (void)setShowCustomCallout:(BOOL)showCustomCallout
    {
        [self setShowCustomCallout:showCustomCallout animated:NO];
    }
    
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# Version 2.0
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2013 updates:
# - fixed the broken "save personal Schemes"
#
# NB: if you are storing "built" products, this WILL NOT WORK,
@ShadoFlameX
ShadoFlameX / UILabel with Content Insets
Created May 7, 2013 20:21
UILabel subclass supporting content edge insets via UIEdgeInsets property.
//
// BHInsetLabel.h
// Created by Bryan Hansen on 5/7/13.
//
#import <UIKit/UIKit.h>
@interface BHInsetLabel : UILabel
@property (nonatomic, assign) UIEdgeInsets contentInsets;
@ShadoFlameX
ShadoFlameX / iOS raw image data
Last active September 21, 2016 08:23
Obtain raw image data from an iOS user's photo library
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSURL *assetURL = info[UIImagePickerControllerReferenceURL];
ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
[assetLibrary assetForURL:assetURL resultBlock:^(ALAsset *asset) {
ALAssetRepresentation *representation = [asset defaultRepresentation];
Byte *buffer = (Byte *)malloc(representation.size);
@ShadoFlameX
ShadoFlameX / Center CGRect in CGRect
Created February 19, 2013 08:38
When doing iOS view layouts I end up needing to center CGRects within a CGRect while maintaining on pixel origin and size. This will do just that.
CG_INLINE CGRect CGRectIntegralCenteredInRect(CGRect innerRect, CGRect outerRect)
{
CGFloat originX = floorf((outerRect.size.width - innerRect.size.width) * 0.5f);
CGFloat originY = floorf((outerRect.size.height - innerRect.size.height) * 0.5f);
return CGRectMake(originX, originY, innerRect.size.width, innerRect.size.height);
}
The future is no longer a synonym for "progress."