ios - 如何创建帮助覆盖图,iOS

标签 ios objective-c iphone swift overlay

<分区>

我正在尝试像下面这张图片那样做一个帮助叠加层,我该怎么做?

enter image description here

最佳答案

喜欢

objective-C

// get window screen size for frame
CGRect screensize = [[UIScreen mainScreen] bounds];
//create a new UIview with the same size for same view
UIView* TransprentView = [[UIView alloc] initWithFrame:screensize];

// change the background color to black and the opacity to 0.6 for Transparent
TransprentView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];

  // here add your Label, Image, etc, what ever you want

// add this TransprentView to your main view
[self.view addSubview:TransprentView];

你可以从 super View 中删除它:

[TransprentView removeFromSuperview];

Swift 2 及更高版本

 let TransprentView =  UIView(frame: UIScreen.mainScreen().bounds)

    TransprentView.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.5)

    // here add your Label, Image, etc, what ever you want

    self.view.addSubview(TransprentView)

你可以从 super View 中删除它:

    TransprentView.removeFromSuperview()

关于ios - 如何创建帮助覆盖图,iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33564627/

相关文章:

javascript - 如何减小 React Native iOS 应用程序的大小?

iphone - 小地方的增强现实 iOS 应用程序 - 可能吗?

ios - PhysicsBody 在平移和旋转后保持不变

objective-c - NSNotificationCenter - 等待通知发布而不阻塞主线程的方法?

iphone - 写入 UITextView

ios - Swift 更复杂的数组字典

ios - CoreData : warning: Unable to load class named 'Task' for entity 'Task' . 找不到类,改用默认的 NSManagedObject

ios - 混合应用程序 (cordova) 中的 IAP - iTunes 收据仅包含第一笔交易

iphone - 呈现 UINavigationController 多个深度 View ,作为初始 View

objective-c - 使用与 NSScrollview 相同的复制技术