Created
September 24, 2012 20:39
-
-
Save odrobnik/3778230 to your computer and use it in GitHub Desktop.
Dynamically Replacing the super class
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
// | |
// DTTextSelectionRect.m | |
// DTRichTextEditor | |
// | |
// Created by Oliver Drobnik on 9/11/12. | |
// Copyright (c) 2012 Cocoanetics. All rights reserved. | |
// | |
#import <objc/runtime.h> | |
#import "DTTextSelectionRect.h" | |
@implementation DTTextSelectionRect | |
+ (void)initialize | |
{ | |
// do we have the iOS 6 class available? | |
if (NSStringFromClass([UITextSelectionRect class])) | |
{ | |
// exchange superclass | |
class_setSuperclass([DTTextSelectionRect class], [UITextSelectionRect class]); | |
} | |
} | |
+ (DTTextSelectionRect *)textSelectionRectWithRect:(CGRect)rect | |
{ | |
return [[DTTextSelectionRect alloc] initWithRect:rect]; | |
} | |
- (id)initWithRect:(CGRect)rect | |
{ | |
self = [super init]; | |
if (self) | |
{ | |
_rect = rect; | |
_writingDirection = UITextWritingDirectionLeftToRight; | |
} | |
return self; | |
} | |
#pragma mark Properties | |
@synthesize rect = _rect; | |
@synthesize writingDirection = _writingDirection; | |
@synthesize containsStart = _containsStart; | |
@synthesize containsEnd = _containsEnd; | |
@synthesize isVertical = _isVertical; | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment