我正在尝试使用
在UITextView周围添加边框 self.textView.layer.borderWidth = 1;
self.textView.layer.borderColor = [[UIColor brownColor] CGColor];
但它没有出现。如果有人能帮助我,为什么它没有出现。尽管我已经添加了Quartz框架。但仍然没有出现。
#import "uitextviewViewController.h"
#import <QuartzCore/QuartzCore.h>
@implementation uitextviewViewController
@synthesize textView;
@synthesize navBar;
- (void)dealloc {
[navBar release];
[textView release];
[super dealloc];
}
- (void) viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem * button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(done:)];
[[self navigationItem] setRightBarButtonItem:button];
[button release];
self.textView = [[[UITextView alloc] initWithFrame:self.view.frame] autorelease];
self.textView.textColor = [UIColor whiteColor];
self.textView.font = [UIFont fontWithName:@"Arial" size:15];
self.textView.delegate = self;
self.textView.backgroundColor = [UIColor brownColor];
self.textView.layer.borderWidth = 1;
self.textView.layer.borderColor = [[UIColor brownColor] CGColor];
self.textView.textAlignment = UITextAlignmentCenter;
self.textView.text = @"This is UITextView\n\nThis is UITextView\n\nThis is UITextView\n\nThis is UITextView\n\nThis is UITextView.";
self.textView.scrollEnabled = YES;
[self.view addSubview: self.textView];
}
我将非常感谢您的帮助。
提前致谢。
答案 0 :(得分:4)
以下代码用于给出UITextbox或其他控制器的弧,您需要使用#import框架工作,然后您可以使用以下代码作为控件上的边框或弧形。
imgThumb.layer.cornerRadius = 5;
imgThumb.layer.masksToBounds = YES;
imgThumb.layer.borderColor = [UIColor grayColor].CGColor;
imgThumb.layer.borderWidth = 0.9;
如果对此有任何疑问,请在此处发表评论...... 快乐的编码
答案 1 :(得分:2)
在这里,使用它。
按照您的喜好修改它。
<强> UITextFieldWrapper.h 强>
#import <UIKit/UIKit.h>
@interface UITextFieldWrapper : UIView
@property (nonatomic, weak, readonly) UITextField * textField;
@end
<强> UITextFieldWrapper.m 强>
#import "UITextFieldWrapper.h"
#import <QuartzCore/QuartzCore.h>
@implementation UITextFieldWrapper
@synthesize textField = _textField;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.layer.borderWidth = 1.0;
self.layer.borderColor = [[UIColor blackColor] CGColor];
self.backgroundColor = [UIColor whiteColor];
self.clipsToBounds = YES;
UITextField * textField = [[UITextField alloc] initWithFrame:CGRectMake(3, 3, frame.size.width - 6, 21)];
textField.backgroundColor = [UIColor whiteColor];
[self addSubview:textField];
_textField = textField;
}
return self;
}
@end