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
402 views
in Technique[技术] by (71.8m points)

iphone - Transparent UIPopover

Is there a way to make the UIPopOver transparent (alpha = 0.75 or so). Unfortunately there is no alpha property for UIPopOver. I need to present a popover so that the view beneath it will still be partially visible. Any ideas

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

Starting with iOS5.0, one can provide a custom background for the UIPopoverController. That background has to be derived from UIPopoverBackgroundView which does provide the normal UIView properties like alpha. Note that the name is a bit confusing - the UIPopoverBackgroundView provides the frame-, the arrow- as well as the background-graphics.

So if you need an entirely semi-transparent UIPopoverController, all you have to do is supply a UIPopoverBackgroundView class which sets its alpha towards something below 1.0. You will also need to make sure that your contentViewController's view is (fully) transparent.

Example:

enter image description here


For details, see the popoverBackgroundViewClass property of UIPopoverController:

popoverBackgroundViewClass

The class to use for displaying the popover background content.

@property (nonatomic, readwrite, retain) Class popoverBackgroundViewClass

Discussion

The default value of this property is nil, which indicates that the popover controller should use the default popover appearance. Setting this property to a value other than nil causes the popover controller to use the specified class to draw the popover’s background content. The class you specify must be a subclass of UIPopoverBackgroundView.

Availability Available in iOS 5.0 and later. Declared In UIPopoverController.h


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

...