iPhone - 使用不透明文本创建半透明矩形 [英] iPhone - Create a semi transparent rectangle with opaque text

查看:131
本文介绍了iPhone - 使用不透明文本创建半透明矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MapView,我想在顶部显示一个黑色的半透明矩形,里面有一个文本。不是在整个地图上只有它的一部分(可能在顶角)就像一个信息框(就像双击时出现的iPod播放器中的一个,显示静音和跳过按钮)。



我试过谷歌,但我没有得到任何明确的答案。如何实现这一目标的最佳方式是什么?



提前致谢

解决方案

可以使用界面构建器轻松完成:





查看层次结构



注意 背景必须是一个单独的视图,它是控件列表中的第一个条目,因此它在后台。将容器视图设置为低于1的alpha值也将由子视图继承,这不会显示在界面构建器中



视图设置具有清晰颜色的视图bg和alpha 1.0





查看黑色半透明bg视图的设置




I have a MapView and I want to display a black semi transparent rectangle on top with a text inside. Not over the entire map only on section of it (maybe on the top corner) just as an info box (like the one in the iPod player that appears on double tap and displays the Mute and skip buttons).

I tried google but I'm not getting any clear answers. How is the best way to accomplish this?

Thanks in advance

解决方案

Can be easily done with interface builder:

View Hierarchy

NOTE The background has to be a separate view which is the first entry in the list of controls, so it is in the background. Setting the container view to an alpha value below 1 will also be inherited by the subviews, which is not displayed in the interface builder

Settings for view "view with clear color bg and alpha 1.0"

Settings for view "black translucent bg view"

这篇关于iPhone - 使用不透明文本创建半透明矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆