<small id='o6ua8'></small><noframes id='o6ua8'>

    • <bdo id='o6ua8'></bdo><ul id='o6ua8'></ul>
  1. <legend id='o6ua8'><style id='o6ua8'><dir id='o6ua8'><q id='o6ua8'></q></dir></style></legend>
    <tfoot id='o6ua8'></tfoot>

    1. <i id='o6ua8'><tr id='o6ua8'><dt id='o6ua8'><q id='o6ua8'><span id='o6ua8'><b id='o6ua8'><form id='o6ua8'><ins id='o6ua8'></ins><ul id='o6ua8'></ul><sub id='o6ua8'></sub></form><legend id='o6ua8'></legend><bdo id='o6ua8'><pre id='o6ua8'><center id='o6ua8'></center></pre></bdo></b><th id='o6ua8'></th></span></q></dt></tr></i><div id='o6ua8'><tfoot id='o6ua8'></tfoot><dl id='o6ua8'><fieldset id='o6ua8'></fieldset></dl></div>

      使用 UIPopoverBackgroundView 类

      时间:2023-06-01

      <small id='3vesG'></small><noframes id='3vesG'>

      <legend id='3vesG'><style id='3vesG'><dir id='3vesG'><q id='3vesG'></q></dir></style></legend>
      • <bdo id='3vesG'></bdo><ul id='3vesG'></ul>
        <i id='3vesG'><tr id='3vesG'><dt id='3vesG'><q id='3vesG'><span id='3vesG'><b id='3vesG'><form id='3vesG'><ins id='3vesG'></ins><ul id='3vesG'></ul><sub id='3vesG'></sub></form><legend id='3vesG'></legend><bdo id='3vesG'><pre id='3vesG'><center id='3vesG'></center></pre></bdo></b><th id='3vesG'></th></span></q></dt></tr></i><div id='3vesG'><tfoot id='3vesG'></tfoot><dl id='3vesG'><fieldset id='3vesG'></fieldset></dl></div>
        <tfoot id='3vesG'></tfoot>

          <tbody id='3vesG'></tbody>

              • 本文介绍了使用 UIPopoverBackgroundView 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                Apple 缺少有关如何使用 iOS5 中引入的 UIPopoverBackgroundView 类的文档.谁有例子?

                Apple is missing documentation on how to use UIPopoverBackgroundView class introduced in iOS5. Anyone have an example?

                我尝试将其子类化,但我在 Lion 上的 XCode 4.2 缺少 UIPopoverBackgroundView.h

                I have tried to subclass it, but my XCode 4.2 on Lion is missing UIPopoverBackgroundView.h

                不出所料,它应该被导入为 #import <UIKit/UIPopoverBackgroundView.h>

                推荐答案

                要添加到其他仅链接的答案,这是如何完成的.

                To add to the other, link-only answers, here is how this is done.

                • 创建一个新的 UIPopoverBackgroundView 子类
                • 在您的界面中声明以下内容:

                • Create a new subclass of UIPopoverBackgroundView
                • Declare the following in your interface:

                +(UIEdgeInsets)contentViewInsets;
                +(CGFloat)arrowHeight;
                +(CGFloat)arrowBase;
                
                @property(nonatomic,readwrite) CGFloat arrowOffset;
                @property(nonatomic,readwrite) UIPopoverArrowDirection arrowDirection;
                

              • 类方法很简单:contentViewInsets返回你的边框的宽度(不包括箭头),arrowHeight是你的高度箭头,arrowBase 是箭头的基础.

              • The class methods are straightforward: contentViewInsets returns the width of your borders all the way round (not including the arrow), arrowHeight is the height of your arrow, arrowBase is the base of your arrow.

                • 背景视图的框架应该是 self.bounds,在箭头所在的边缘由 arrowHeight 插入
                • 箭头视图的框架应对齐,使中心远离self中心arrowOffset(根据轴正确).如果箭头方向不向上,您必须更改图像方向,但我的弹出框只会向上,所以我没有这样做.
                • The frame of your background view should be self.bounds, inset by arrowHeight on whatever edge the arrow is on
                • The frame of the arrow view should be aligned so that the centre is arrowOffset away from the centre of self (correct according to the axis). You have to change the image orientation if the arrow direction is not up, but my popover would only be up so I didn't do that.

                这是我的 Up-only 子类的 layoutSubviews 方法:

                Here is the layoutSubviews method for my Up-only subclass:

                -(void)layoutSubviews
                {
                    if (self.arrowDirection == UIPopoverArrowDirectionUp)
                    {
                        CGFloat height = [[self class] arrowHeight];
                        CGFloat base = [[self class] arrowBase];
                
                        self.background.frame = CGRectMake(0, height, self.frame.size.width, self.frame.size.height - height);
                
                        self.arrow.frame = CGRectMake(self.frame.size.width * 0.5 + self.arrowOffset - base * 0.5, 1.0, base, height);
                        [self bringSubviewToFront:self.arrow];
                
                    }
                }
                

                这篇关于使用 UIPopoverBackgroundView 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

              • 上一篇:iOS Core蓝牙不要求配对 下一篇:weak 和 unsafe_unretained 的区别

                相关文章

                最新文章

              • <small id='fWrN5'></small><noframes id='fWrN5'>

                  <tfoot id='fWrN5'></tfoot>

                    <legend id='fWrN5'><style id='fWrN5'><dir id='fWrN5'><q id='fWrN5'></q></dir></style></legend>

                    • <bdo id='fWrN5'></bdo><ul id='fWrN5'></ul>
                    <i id='fWrN5'><tr id='fWrN5'><dt id='fWrN5'><q id='fWrN5'><span id='fWrN5'><b id='fWrN5'><form id='fWrN5'><ins id='fWrN5'></ins><ul id='fWrN5'></ul><sub id='fWrN5'></sub></form><legend id='fWrN5'></legend><bdo id='fWrN5'><pre id='fWrN5'><center id='fWrN5'></center></pre></bdo></b><th id='fWrN5'></th></span></q></dt></tr></i><div id='fWrN5'><tfoot id='fWrN5'></tfoot><dl id='fWrN5'><fieldset id='fWrN5'></fieldset></dl></div>