简体   繁体   English

这个“弹出”视图是如何创建的?

[英]How was this 'pop-up' view created?

Please see the image below. 请参见下图。

How was this 'pop-up' view created? 这个“弹出”视图是如何创建的? Suppose I wanted to completely imitate that view with the fonts, how would I do so? 假设我想使用字体完全模仿该视图,我该怎么做?

在此处输入图片说明

There is not a SDK exposed component for this, but this could very easily be made using a hierarchy of views: 没有为此提供SDK公开的组件,但是可以使用视图层次结构很容易地做到这一点:

UIView - Main view. UIView-主视图。 Uses a bezier path to create a protrusion to point from the source. 使用贝塞尔曲线路径创建从源指向的突出。 Has a border and drop shadow added to its layer. 在其图层上添加了边框和阴影。

UIButton - Smaller font UIButton-较小的字体
UIButton - Larger font UIButton-较大的字体
UIButton - Change font type UIButton-更改字体类型
UIButton - Container for sepia. UIButton-棕褐色的容器。
UILabel - "Sepia" text UISwitch - turning sepia on and off UILabel-“棕褐色”文本UISwitch-打开和关闭棕褐色

Just show and hide the view with an animation. 只需使用动画显示和隐藏视图即可。 Also, create delegate callbacks to tell the delegate when events occur in the popover. 另外,创建委托回调,以在弹出窗口中发生事件时告诉委托。

// Delegate returns if the text can get smaller to enable/disable the button
- (BOOL) didSelectSmallerFont:(CGFloat)fontSize;
// Delegate returns if the text can get larger to enable/disable the button
- (BOOL) didSelectLargerFont:(CGFloat)fontSize; 
- (void) didChangeFont:(UIFont*)font;
- (void) didToggleSepia:(BOOL)enabled;

etc. 等等

The pyramid shape is not associated with the button that was clicked to present the popup. 金字塔形状与单击以显示弹出窗口的按钮无关。 It would be a subview of the popup view, either a UIImageView or possibly drawn on a UIView, although a UIImageView would be the easier solution. 它可以是弹出视图的子视图,可以是UIImageView或可以在UIView上绘制,尽管UIImageView是更简单的解决方案。 You could definitely code the popup view to point that arrow at any point on the screen or in any direction. 您绝对可以对弹出视图进行编码,以将该箭头指向屏幕上的任意位置或任何方向。 What I would do is instantiate the popup by means of an init method called initFromPoint: , then pass the center value of the button used to launch the popup. 我要做的是通过称为initFromPoint:的init方法实例化弹出窗口,然后传递用于启动弹出窗口的按钮的中心值。 Then within the viewDidLoad method of the popup place the point appropriately based on the point. 然后在弹出窗口的viewDidLoad方法中,根据该点适当放置该点。

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

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