【问题标题】:Paintcode generated iOS code for custom button(not working)Paintcode 为自定义按钮生成 iOS 代码(不工作)
【发布时间】:2014-03-09 15:47:59
【问题描述】:

我正在使用 Paintcode 为我的应用创建圆形按钮。我遵循的步骤是 - 创建为 UIButton 派生的新类,将由paintcode 生成的代码粘贴到 (void)drawRect:(CGRect)rect 中并设置按钮以使用我的自定义类。但是我做错了,因为按钮根本没有任何形状,它只是一个标签。这是我使用的代码 -

//// Color Declarations
UIColor* strokeColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 1];
UIColor* fillColor2 = [UIColor colorWithRed: 0.886 green: 0 blue: 0 alpha: 1];

//// Rounded Rectangle Drawing
UIBezierPath* roundedRectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(44.5, 45.5, 48, 20) cornerRadius: 4];
[fillColor2 setFill];
[roundedRectanglePath fill];
[strokeColor setStroke];
roundedRectanglePath.lineWidth = 1;
[roundedRectanglePath stroke];

【问题讨论】:

    标签: ios custom-controls paintcode


    【解决方案1】:
    //// Color Declarations
    UIColor* strokeColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 1];
    UIColor* fillColor2 = [UIColor colorWithRed: 0.886 green: 0 blue: 0 alpha: 1];
    
    //// Frames: Set frame to "rect" to have the custom button fit in the UIButton frame
    CGRect frame = CGRectMake(45, 45, 48, 20);
    
    
    //// CustomButton
    {
        //// Rounded Rectangle Drawing
        UIBezierPath* roundedRectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(CGRectGetMinX(frame) + 1.5, CGRectGetMinY(frame) + 0.5, CGRectGetWidth(frame) - 3, CGRectGetHeight(frame) - 2) cornerRadius: 4];
        [fillColor2 setFill];
        [roundedRectanglePath fill];
        [strokeColor setStroke];
        roundedRectanglePath.lineWidth = 1;
        [roundedRectanglePath stroke];
    }
    

    【讨论】:

      猜你喜欢
      • 2021-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-02
      • 1970-01-01
      • 2023-03-23
      • 2016-10-03
      • 2015-11-24
      相关资源
      最近更新 更多