【问题标题】:Generated image in iOS app looks different from original vector imageiOS 应用程序中生成的图像看起来与原始矢量图像不同
【发布时间】:2023-03-29 10:57:01
【问题描述】:

我在 xcode 图像资源中添加了一个 PDF 矢量文件。矢量文件有颜色和设计。但是,在模拟器上生成的时候,形状保留了,但是颜色和设计都没有了,换成了纯色。

// code to add the button
- (void) addReplyButton:(STRContent *)content {
    UIButton *replyBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    replyBtn.frame = CGRectMake(0, 0, 0, 0);
    [[replyBtn imageView] setContentMode: UIViewContentModeScaleAspectFit];
    [replyBtn setImage:[UIImage imageNamed:@"reply_button"] forState:UIControlStateNormal];
    [self.photoView addSubview:replyBtn];
}

原图

输出

【问题讨论】:

  • 每次都会发生吗?或者有时显示正确的图像?

标签: ios vector uiimage xcode6


【解决方案1】:

我发现了问题 - 我正在做 UIButtonTypeRoundedRect,而 UIBottomtypeCustom 工作的地方。

UIButton *replyBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

【讨论】:

    【解决方案2】:

    我之前也遇到过类似的问题,就我而言,有两个文件具有相同的文件名。

    在这种情况下,它通过在同名中随机选择来显示图像

    【讨论】:

      猜你喜欢
      • 2015-02-13
      • 1970-01-01
      • 2022-12-15
      • 1970-01-01
      • 1970-01-01
      • 2023-04-11
      • 2014-10-30
      • 2019-01-30
      • 2020-03-17
      相关资源
      最近更新 更多