Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
470 views
in Technique[技术] by (71.8m points)

uiview - iPhone - Create a semi transparent rectangle with opaque text

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Can be easily done with interface builder:

enter image description here

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

enter image description here

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

enter image description here

Settings for view "black translucent bg view"

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...