Ios 我的CGFrame不显示
我正在尝试使用下面的代码构建一个使用CGFrame的示例Ios 我的CGFrame不显示,ios,xcode4,quartz-graphics,cgrect,Ios,Xcode4,Quartz Graphics,Cgrect,我正在尝试使用下面的代码构建一个使用CGFrame的示例 - (void)viewDidLoad { [super viewDidLoad]; CGRect newFrame = [note_view frame]; if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) newFrame.size.height += 223;
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect newFrame = [note_view frame];
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
newFrame.size.height += 223;
else
newFrame.size.height += 70;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationOptionCurveEaseInOut];
[note_view setFrame:newFrame];
[UIView commitAnimations];
}
框架将不显示,我只得到一个空白屏幕,我缺少什么?我在您的代码中发现了一个问题 问题:你没有给出便笺视图的宽度,这意味着它被视为
0
,这就是为什么你的便笺视图在设置宽度并检查后不可见的原因
note_view.frame=CGRectMake(0,0,100,10)
- (void)loadView {
[super loadView];
NSString *pupil;
UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(saveAndExit)];
[[self navigationItem] setLeftBarButtonItem:done];
UIBarButtonItem *date = [[UIBarButtonItem alloc] initWithTitle:@"Date Notes" style:UIBarButtonItemStyleBordered target:self action:@selector(dateNote)];
[[self navigationItem] setRightBarButtonItem:date];
[[self navigationItem] setTitle:@"Notes - " ];
note_view = [[UITextView alloc] init];
[note_view setBackgroundColor:[UIColor whiteColor]];
[note_view setFont:[UIFont systemFontOfSize:17]];
[[note_view layer] setCornerRadius:5];
[[note_view layer] setBorderWidth:2];
[[note_view layer] setBorderColor:[[UIColor colorWithRed:0.3882352941 green:0.6 blue:0.8117647059 alpha:1] CGColor]];
[[note_view layer] setShadowOpacity:1];
[[note_view layer] setShadowColor:[[UIColor colorWithRed:0.3882352941 green:0.6 blue:0.8117647059 alpha:1] CGColor]];
[[note_view layer] setShadowRadius:10];
[[note_view layer] setMasksToBounds:NO];
[[self view] addSubview:note_view];
}
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])){
newFrame.size.height += 223;
newFrame.size.width = 100;
}
else
{
newFrame.size.height += 70;
newFrame.size.width = 100;
}