This file contains hidden or 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
// | |
// WCAttributedString.h | |
// iOS | |
// | |
// Created by Wess Cope on 3/19/12. | |
// | |
// Special Thanks to Erica Sadun's Cookbook For the following, updated just a bit. | |
// | |
#import <Foundation/Foundation.h> |
This file contains hidden or 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
#define ARTICLE_IMAGE_BORDER_SIZE 4.0f | |
@implementation LOArticleContentView | |
@synthesize text = _text; | |
@synthesize image = _image; | |
- (id)initWithFrame:(CGRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
if (self) |
This file contains hidden or 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
(function(){ | |
var imagePreload = function(imageUrlList) | |
{ | |
for(var i = 0; i < imageUrlList.length; i++) | |
{ | |
var image = new Image(); | |
image.src = imageUrlList[i]; | |
} | |
} |
This file contains hidden or 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
[WCXMLParser parseXMLString:operation.responseString withOptions:0 success:^(WCXMLParser *parser, id parsedObject) { | |
NSLog(@"PARSED: %@", parsedObject); | |
} failure:^(WCXMLParser *parser, NSError *error) { | |
NSLog(@"ERROR: %@", [error description]); | |
}]; |
This file contains hidden or 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
static CGRect clipRectToPath(CGRect rect, CGPathRef path) | |
{ | |
size_t width = floorf(rect.size.width); | |
size_t height = floorf(rect.size.height); | |
uint8_t *points = calloc(width * height, sizeof(*points)); | |
CGContextRef bitmapContext = CGBitmapContextCreate(points, width, height, sizeof(*points) * 8, width, NULL, kCGImageAlphaOnly); | |
BOOL atStart = NO; | |
NSRange range = NSMakeRange(0, 0); | |
NSUInteger x = 0; |
This file contains hidden or 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
- (CGSize)sizeForAttributedStringWithWidth:(CGFloat)width | |
{ | |
CTTypesetterRef typesetter = CTTypesetterCreateWithAttributedString((__bridge CFAttributedStringRef)self); | |
CFIndex offset = 0, length; | |
CGFloat y = 0; | |
do { | |
length = CTTypesetterSuggestLineBreak(typesetter, offset, width); | |
CTLineRef line = CTTypesetterCreateLine(typesetter, CFRangeMake(offset, length)); | |
This file contains hidden or 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
- (CGFloat)getContentHeight | |
{ | |
CTFramesetterRef tmpFrameSetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)_body); | |
int textLength = [_body length]; | |
CFRange range; | |
CGFloat maxWidth = self.width; | |
CGFloat maxHeight = CGFLOAT_MAX; | |
CGSize constraint = CGSizeMake(maxWidth, maxHeight); | |
CGSize contentSize = CTFramesetterSuggestFrameSizeWithConstraints(tmpFrameSetter, CFRangeMake(0, textLength), nil, constraint, &range); |
This file contains hidden or 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
// A small chunk of it. | |
- (void)tapGestureAction:(UITapGestureRecognizer *)gesture | |
{ | |
CGPoint location = [gesture locationInView:self]; | |
_linkLocation = location; | |
location.y += (ARTICLE_BODY_FONT_SIZE / lineHeightFactor); | |
CFArrayRef lines = CTFrameGetLines(_frame); | |
This file contains hidden or 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
// Supports --foo=bar and -f bar | |
static NSDictionary *arguments() | |
{ | |
NSArray *arguments = [[NSProcessInfo processInfo] arguments]; | |
if(arguments.count < 2) | |
return nil; | |
NSMutableDictionary *argsDict = [[NSMutableDictionary alloc] init]; |
This file contains hidden or 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
[PRouter addOption:@[@"n", @"new"] callback:^(NSString *value) { | |
NSDictionary *manifest = @{ | |
@"name" : @"", | |
@"description" : @"", | |
@"version" : @"", | |
@"author" : @"", | |
@"url" : @"", | |
@"keywords" : @[] | |
}; |