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

视图中的图形选项卡

  •  0
  • calvinlough  · 技术社区  · 16 年前

    3 回复  |  直到 16 年前
        1
  •  2
  •   Peter Hosey    16 年前

    您可以做的是让选项卡在代码中绘制,然后简单地不绘制背景。让窗口的背景(活动或非活动)显示出来。

    您也可以考虑切换到 PSMTabBarControl

        2
  •  0
  •   lucius    16 年前

    我执行非活动控件的方法是在图形程序(Photoshop或Illustrator)中呈现同一图形的非活动状态版本,并在需要时绘制非活动版本。如果绘制活动图像的50%透明版本,则需要先用背景色擦除。

        3
  •  0
  •   caleb    16 年前

    可以尝试使用半透明遮罩绘制图像。我通常使用的代码只是绘制一个图像,然后使用Quartz的透明层功能在图像的实际边界上填充一个矩形。我将此作为NSImage上的一个类别:

    @implementation NSImage (ShadedImageAddition)
    - (void)drawAtPoint:(NSPoint)point shadeWithColor:(NSColor *)color intensity:(CGFloat)alpha
    {
        NSRect imageRect;
        CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
    
        imageRect.origin = point;
        imageRect.size = [self size];
    
        CGContextBeginTransparencyLayerWithRect(context, NSRectToCGRect(imageRect), NULL);
    
        [self drawInRect:imageRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
        [[color colorWithAlphaComponent:alpha] setFill];
        NSRectFillUsingOperation(imageRect, NSCompositeSourceAtop);
    
        CGContextEndTransparencyLayer(context);
    }
    @end
    

    [myImage drawAtPoint:NSZeroPoint shadeWithColor:[NSColor whiteColor] intensity:0.50];