【问题标题】:Customise Message center of Apptentive iOS Objective C自定义 Apptentive iOS Objective C 的消息中心
【发布时间】:2017-06-02 10:55:14
【问题描述】:

我正在使用 Apptentive,并且我正在尝试自定义相同的消息中心。我想更改“ApptentiveColorContextBackground”颜色,但我无法弄清楚它从哪里更改 link 表示用户可以修改 UI。

任何帮助都会很棒!

已编辑:-

试过了

在 ApptentiveMessageCenterViewController.m 中

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    switch ([self.dataSource cellTypeAtIndexPath:indexPath]) {
        case ATMessageCenterMessageTypeMessage:
        case ATMessageCenterMessageTypeCompoundMessage:

            [(ApptentiveStyleSheet *)Apptentive.shared.styleSheet setColor:[UIColor redColor] forStyle:ApptentiveColorMessageBackground];
            cell.contentView.backgroundColor = [[Apptentive sharedConnection].styleSheet colorForStyle:ApptentiveColorMessageBackground];

            break;
        case ATMessageCenterMessageTypeReply:
        case ATMessageCenterMessageTypeCompoundReply:
            cell.contentView.backgroundColor = [[Apptentive sharedConnection].styleSheet colorForStyle:ApptentiveColorReplyBackground];

        case ATMessageCenterMessageTypeContextMessage:

            [(ApptentiveStyleSheet *)Apptentive.shared.styleSheet setColor:[UIColor redColor] forStyle:ApptentiveColorContextBackground];

            cell.contentView.backgroundColor = [[Apptentive sharedConnection].styleSheet  colorForStyle:ApptentiveColorContextBackground];

    }
}

【问题讨论】:

  • 看起来不错,但您应该将 -setColor:forStyle: 调用移至 -application:didFinishLaunchingWithOptions 之类的名称中。
  • 另外,4.0.5 之前的 SDK 版本中存在 goto fail 样式的错误,导致回复单元格无法正确着色。

标签: ios message apptentive


【解决方案1】:

初始化时,Apptentive 单例将其styleSheet 属性设置为ApptentiveStyleSheet 的实例。

您可以修改一些内置的颜色属性(前景、背景等),所有其他颜色都源自这些属性。

您还可以按如下方式覆盖特定颜色(或字体)(Swift):

if let style = Apptentive.sharedConnection().styleSheet as? ApptentiveStyleSheet {
    style.setColor(UIColor.red, forStyle: ApptentiveColorContextBackground)
}

或者在 Objective-C 中:

[(ApptentiveStyleSheet *)Apptentive.shared.styleSheet setColor:[UIColor redColor] forStyle:ApptentiveColorContextBackground];

您需要在应用生命周期的早期进行这些覆盖,例如在-application:didFinishLaunchingWithOptions: 中。

您还可以创建自己的对象来实现 ApptentiveStyle 协议(并将其设置在 Apptentive 单例上),但您必须继承 ApptentiveStyleSheet 或做大量工作才能返回有效所有样式/颜色的颜色和字体。

【讨论】:

  • 我在我们的开发应用程序(Swift 和 Obj-C)中运行了我的代码,它把背景变成了红色。您的代码似乎应该可以工作(如果您#import "ApptentiveStyleSheet.h"),但在应用生命周期的早期设置一次颜色会更有效,并且您应该尽可能避免编辑 SDK 代码使升级更容易。
  • 能否告诉我如何为 ApptentiveMessageCenterReplyCell 设置颜色?我已经发布了你可以查看的问题。stackoverflow.com/questions/47032316/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-10
  • 1970-01-01
相关资源
最近更新 更多