1

I am using Apptentive, and i am trying to customise message center of same.I want to change "ApptentiveColorContextBackground" color, but i am unable to figure out from where it changes the link says user can modify the UI.

Any help will be great.!

Edited :-

Tried this

in 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];

    }
}
Zღk
  • 854
  • 7
  • 25
  • That looks right, but you should move the `-setColor:forStyle:` call into something like `-application:didFinishLaunchingWithOptions`. – Frank Schmitt Jun 14 '17 at 00:21
  • Also, there was a `goto fail`-style bug in SDK versions prior to 4.0.5 that prevented reply cells from being colored correctly. – Frank Schmitt Nov 01 '17 at 18:19

1 Answers1

0

When it's initialized, the Apptentive singleton sets its styleSheet property to an instance of ApptentiveStyleSheet.

There are a few built-in color properties you can modify (foreground, background, and so on), from which all of the other colors are derived.

You can also override a specific color (or font) as follows (Swift):

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

Or in Objective-C:

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

You'll want to do these overrides early in the app lifecycle, for instance in -application:didFinishLaunchingWithOptions:.

You can also create your own object that implements the ApptentiveStyle protocol (and set it on the Apptentive singleton), but you'll have to either subclass ApptentiveStyleSheet or do a fair amount of work to return valid colors and fonts for all of the styles/colors.

Frank Schmitt
  • 25,648
  • 10
  • 58
  • 70
  • I ran my code in our dev app (both Swift and Obj-C) and it turns the background red. Your code seems like it *should* work (if you `#import "ApptentiveStyleSheet.h"`), but it's more efficient to just set the color once early in the app lifecycle, and you should avoid editing the SDK code if at all possible to make upgrading easier. – Frank Schmitt Jun 14 '17 at 00:15
  • Could you please let me know how to set color for ApptentiveMessageCenterReplyCell? I have posted question you could check it.https://stackoverflow.com/questions/47032316/apptentive-apptentivemessagecenterreplycell-color-change – Nagarjun Oct 31 '17 at 09:54