繁体   English   中英

ios-在另一个UIView中将UIView子类化?

[英]ios - Subclassing an UIView inside another UIView?

我有2个UIViews,其中都有一些代码。

我可以将一个子类self.view addSubView:_msgView];给UIViewController,例如self.view addSubView:_msgView]; _msgView是UIView。

现在,_msgView是一个普通的UIView,它具有0.7 Alpha放在UIViewController上。

现在我有另一个UIView叫做menuButtons,我想把它放在_msgView的顶部。

我以为我可以使用[_msgView addSubView:_menuButton]; 但这不起作用并且发出警告

不兼容的指针类型将“ MenuButtons * __ strong”发送到“ UIView *”类型的参数

如何将一个UIView放在另一个UIView之上?

//编辑:

#import <UIKit/UIKit.h>
#import "SlideMessageView.h"
#import "definitions.h"


@interface MenuButtons : UIView
{
UIButton *onBack;
UIButton *onForward;
UIButton *onRefresh;
UIButton *onHome;
UIButton *onSafari;
UIButton *onChrome;
UIButton *onPocketReader;
UIButton *onSavePDF;
UIButton *onPrint;
UIButton *onShare;

SlideMessageView *msgView;

BOOL viewVisible;
}

UIButton在其下方设置了@properties。

您做1件事..如果您通过代码生成两个视图,则将两个视图添加到self.view本身中并分别设置其框架。

即,如果第一个视图位于顶部,则设置框架msgview.frame = CGRectMake(0,0,320,100); 第二个视图的ans someview.frame = CGRectMake(0,100,320,200);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM