我的观点如下:
_myController = [[MSCustomViewController alloc] init];
_myController.doc = (AWDOC *)_currentDocumentViewController.activeFile.document;
_myController.view.backgroundColor = [UIColor colorWithHue:0.7/3.3 saturation:0.2 brightness:1.0 alpha:1.0];
[self.view insertSubview:_myController.view aboveSubview:_myController];
CGSize size = [_myController.view sizeThatFits:CGSizeZero];
if(size.height < _myController.frame.size.height)
size.height = _myController.frame.size.height;
CGRect myFrame = CGRectMake(0., CGRectGetMinY(_currentDocumentViewController.view.bounds) + (CGRectGetHeight(_currentDocumentViewController.view.bounds) - size.height) / 2., size.width, size.height);
_myController.view.frame = myFrame;
CGRect buttonFrame = CGRectMake(CGRectGetMaxX(myFrame), CGRectGetMinY(myFrame), myButton.frame.size.width, CGRectGetHeight(myFrame));
_myButton.frame = buttonFrame;
[_myButton setTitle:@"<" forState:UIControlStateNormal];
什么意思是“用上下文或Draw绘制这个视图”?
答案 0 :(得分:1)
将默认UIView添加到viewcontroller以保存内置视图,如UIButton,UIImageView,UILabel。您可以添加为:
UIView *view = [[[UIView alloc] initwithFrame:CGRectMake(..)];
现在,要在UIView中制作自定义绘图,您必须定义自己的视图(通过创建继承UIView的新类来实现)。假设您创建的类是StandardView类。 继承UIView时,drawRect:是在视图控制器中初始化此uiview时调用的默认方法:
Standardview * stndView = [[Standardview alloc]initWithFrame:CGRectMake(0, 0, 320, 300];
因此,您可以将所有绘图内容放在drawRect:方法中。通常你使用OpenGL / ES或CoreGraphics进行绘图。当使用coregraphics函数时,您可以为coregraphics的每个函数指定上下文。该上下文表示您的图形目标。