Customise Message center of Apptentive iOS Objective C

156 views Asked by At

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

    }
}
1

There are 1 answers

2
Frank Schmitt On

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.