Skip to content

Instantly share code, notes, and snippets.

2010-08-28 21:00:49.045 CTTest[22262:a0f] aaaaa{
NSFont = "\"Helvetica 96.00 pt. P [] (0x10019b1a0) fobj=0x10019b1a0, spc=26.67\"";
NSUnderline = 9;
}
#import <UIKit/UIKit.h>
@interface MyAwesomeView : UIView
{
UILabel *textLabel;
UIButton *button;
NSUInteger counter;
}
#import "MyAwesomeView.h"
@interface MyAwesomeView ()
- (void)updateDisplay;
@end
@implementation MyAwesomeView
@synthesize textLabel;
- (void)dealloc;
for (id p in self.lines)
{
//if (i >= self.numberOfLines && self.numberOfLines)
// break;
CGPoint origin = self.lineOrigins[i++];
CGContextSetTextPosition(ctx, origin.x , origin.y);
CTLineRef line = (CTLineRef)p;
CGFloat ascent, descent, leading;
- (void)drawRect:(CGRect)rect;
{
CGAffineTransform flipVertical = CGAffineTransformMake(1, 0, 0, -1, 0, CGRectGetHeight(self.bounds));
CTFramesetterRef ref = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)self.attributedString);
UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.bounds];
CTFrameRef ctFrame = CTFramesetterCreateFrame(ref, CFRangeMake(0, 0), [path CGPath], NULL);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextConcatCTM(ctx, flipVertical);
+ (id)sharedInstance
{
static id sharedInstance;
static dispatch_once_t once;
dispatch_once(&once, ^{ sharedInstance = [[self alloc] init]; });
return sharedInstance;
}
#import "PrivatesTestViewController.h"
@interface PrivatesTestViewController (Privates)
@property (nonatomic, retain) IBOutlet UIView *testView;
@end
@interface PrivatesTestViewController ()
@property (nonatomic, retain) UIView *testView;
@end
#import "JWPatternImageView.h"
@implementation JWPatternImageView
@synthesize patternImage;
- (void)dealloc;
{
self.patternImage = nil;
[super dealloc];
}
- (void)drawRect:(CGRect)rect;
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetBlendMode(ctx, kCGBlendModeCopy);
CGContextDrawImage(ctx, (CGRect){CGPointZero, self.topImage.size}, [self.topImage CGImage]);
CGContextSaveGState(ctx);
CGContextClipToRect(ctx, CGRectMake(0, self.topImage.size.height, self.bounds.size.width, self.bounds.size.height - self.topImage.size.height - self.bottomImage.size.height));
CGContextDrawTiledImage(ctx, (CGRect){CGPointZero, self.middleImage.size}, [self.middleImage CGImage]);
CGContextRestoreGState(ctx);
@implementation UIView (Responder)
- (UIView *)currentFirstResponder;
{
for (UIView *view in [self subviews])
{
if ([view isFirstResponder])
return view;
if (![view isKindOfClass:[UIControl class]])
{
UIView *subview = [view currentFirstResponder];