简体   繁体   English

具有包含内容的自定义形状框架的UIView

[英]UIView with a custom shaped frame containing content

I would like to take 我想拿 这个图片 and place some UIViews inside the empty area. 并将一些UIViews放在空白区域内。

How can I create a custom container view (the phone) with a "content" area that is equal to that empty space and is resizable? 如何创建一个自定义容器视图 (电话),其“内容”区域等于该空白空间并可以调整大小?

I was using trial and error to get its sub views in there, but as soon as I resized the phone view, it all went out of whack. 我使用反复试验来获取其子视图 ,但是一旦我调整了电话视图的大小,它们就全部消失了。

You can take an ImageView and set the image above now have the set the frame of the view or views you want to add according to the frame u mentioned above 您可以拍摄一个ImageView并设置上面的图像,现在已经根据上面提到的框架设置了一个或多个要添加的视图的框架

CGRect  viewRect = CGRectMake(10, 40, 320, 480);
UIView* myView = [[UIView alloc] initWithFrame:viewRect];
[imageview addSubview:myView];

If you want to add multiple view and want to slide the views you can take an Array of views and use page control. 如果要添加多个视图并希望滑动视图,则可以采用“视图数组”并使用页面控件。

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

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