Created
July 10, 2011 18:51
-
-
Save pix0r/1074843 to your computer and use it in GitHub Desktop.
CustomTextView (UITextView subclass with border)
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
// | |
// CustomTextView.h | |
// | |
// Created by Mike Matz on 7/10/11. | |
// Copyright 2011 Flying Yeti. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface CustomTextView : UITextView { | |
CGFloat _cornerRadius; | |
CGFloat _borderWidth; | |
UIColor *_borderColor; | |
} | |
@property (nonatomic, assign) CGFloat cornerRadius; | |
@property (nonatomic, assign) CGFloat borderWidth; | |
@property (nonatomic, retain) UIColor *borderColor; | |
@end |
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
// | |
// CustomTextView.m | |
// | |
// Created by Mike Matz on 7/10/11. | |
// Copyright 2011 Flying Yeti. All rights reserved. | |
// | |
#import "CustomTextView.h" | |
#import <QuartzCore/QuartzCore.h> | |
@implementation CustomTextView | |
@synthesize cornerRadius = _cornerRadius, borderColor = _borderColor, borderWidth = _borderWidth; | |
- (id)initWithFrame:(CGRect)frame { | |
self = [super initWithFrame:frame]; | |
if (self) { | |
self.cornerRadius = 0.0; | |
self.borderWidth = 0.0; | |
self.borderColor = nil; | |
} | |
return self; | |
} | |
- (void)dealloc { | |
[_borderColor release]; | |
[super dealloc]; | |
} | |
- (void)layoutSubviews { | |
CALayer *layer = self.layer; | |
layer.cornerRadius = self.cornerRadius; | |
layer.borderWidth = self.borderWidth; | |
layer.borderColor = self.borderColor.CGColor; | |
[super layoutSubviews]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment