代码之家  ›  专栏  ›  技术社区  ›  bpapa

主屏幕上的“X”删除按钮是SDK的一部分吗?

  •  3
  • bpapa  · 技术社区  · 14 年前

    所以,当你想从主屏幕上删除一个应用程序,或者从iBooks中删除一本书时,当你进入“编辑模式”时,在app图标/book/任何东西的左上角会有一个小的X位。

    这个按钮是SDK的一部分吗?

    还有。。。如果没有(我很确定不是),有人知道一个可能包含X图像的苹果示例项目吗?

    3 回复  |  直到 14 年前
        1
  •  5
  •   Greg    14 年前

    你可以试试看跳板.app. (Springboard是iOS中的主屏幕。)它应该位于如下位置:

    /开发者/平台/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*十、 Y.Z*.sdk/System/Library/CoreServices/跳板.app/

    编辑: 根据下面的注释,4.1 simulator sdk的映像位置是:

    /开发者/平台/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/System/Library/CoreServices/SpringBoard.app/closebox.png/开发者/平台/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/System/Library/CoreServices/SpringBoard.app/closebox\@2x.png

        2
  •  2
  •   Brad Larson    14 年前

    如果您有兴趣使用Quartz绘制此图,那么下面的代码将从我创建的CALayer中提取,该CALayer是为了呈现这种删除按钮:

    #define SPACETOEXPANDDELETELAYERFORSHADOW 4.0f
    #define FRACTIONOFVIEWFORSTARTANDSTOPOFCROSSLINES 0.38
    
    - (void)renderAsVectorInContext:(CGContextRef)context;
    {
        if (strokeColor == NULL)
            return;
    
        CGContextSetLineJoin(context, kCGLineJoinBevel);
        CGContextSetStrokeColorWithColor(context, strokeColor);
        CGContextSetLineWidth(context, strokeWidth);
        CGContextSetLineCap(context, kCGLineCapRound);
        CGRect currentFrame = self.bounds;
        currentFrame = CGRectInset(currentFrame, SPACETOEXPANDDELETELAYERFORSHADOW, SPACETOEXPANDDELETELAYERFORSHADOW);
    
        CGContextSetShadow(context, CGSizeMake(2.0f, 2.0f), 2.0f);
        CGContextFillEllipseInRect(context, CGRectMake(currentFrame.origin.x + strokeWidth, currentFrame.origin.y + strokeWidth, currentFrame.size.width - (2.0f * strokeWidth), currentFrame.size.height - (2.0f * strokeWidth)));
        CGContextStrokeEllipseInRect(context, CGRectMake(currentFrame.origin.x + strokeWidth, currentFrame.origin.y + strokeWidth, currentFrame.size.width - (2.0f * strokeWidth), currentFrame.size.height - (2.0f * strokeWidth)));
    
        CGContextSetLineWidth(context, 1.3f * strokeWidth);
        CGContextBeginPath(context);
    
        CGContextMoveToPoint(context, currentFrame.origin.x + FRACTIONOFVIEWFORSTARTANDSTOPOFCROSSLINES * currentFrame.size.width, currentFrame.origin.y + FRACTIONOFVIEWFORSTARTANDSTOPOFCROSSLINES * currentFrame.size.height);
        CGContextAddLineToPoint(context, currentFrame.origin.x + (1.0f - FRACTIONOFVIEWFORSTARTANDSTOPOFCROSSLINES) * currentFrame.size.width, currentFrame.origin.y + (1.0f - FRACTIONOFVIEWFORSTARTANDSTOPOFCROSSLINES) * currentFrame.size.height);
        CGContextMoveToPoint(context, currentFrame.origin.x + (1.0f - FRACTIONOFVIEWFORSTARTANDSTOPOFCROSSLINES) * currentFrame.size.width, currentFrame.origin.y + FRACTIONOFVIEWFORSTARTANDSTOPOFCROSSLINES * currentFrame.size.height);
        CGContextAddLineToPoint(context, currentFrame.origin.x + FRACTIONOFVIEWFORSTARTANDSTOPOFCROSSLINES * currentFrame.size.width, currentFrame.origin.y + (1.0f - FRACTIONOFVIEWFORSTARTANDSTOPOFCROSSLINES) * currentFrame.size.height);
    
        CGContextStrokePath(context);
    }
    

    在这种情况下, strokeColor 是一个白色的CGColorRef,层是31 x 31,并且 strokeWidth 是2.0。

        3
  •  0
  •   chuckSaldana    14 年前

    如果要使用此图像,只需:

    • 用photoshop使背景透明
    • 将图像添加到自定义UIButton。

    抱歉,我不记得有任何项目使用它。。。