ChrisXu / CXAlertView

Custom alert-view which allow you to add view as main content.
MIT License
323 stars 81 forks source link

Message isn't customizable, e.g. font, color. #40

Closed larryonoff closed 8 years ago

ChrisXu commented 9 years ago
- (id)initWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle
{
    _vericalPadding = kDefaultVericalPadding;
    _containerWidth = kDefaultContainerWidth;

    UILabel *messageLabel = [[UILabel alloc] init];
    messageLabel.textAlignment = NSTextAlignmentCenter;
    messageLabel.backgroundColor = [UIColor clearColor];
    messageLabel.font = [UIFont systemFontOfSize:14.0];
    messageLabel.textColor = [UIColor blackColor];
    messageLabel.numberOfLines = 0;
    messageLabel.text = message;
    messageLabel.frame = CGRectMake( self.vericalPadding, 0, self.containerWidth - self.vericalPadding*2, [self heightWithText:message font:messageLabel.font]);

    messageLabel.lineBreakMode=LBM;

    return  [self initWithTitle:title contentView:messageLabel cancelButtonTitle:cancelButtonTitle];
}

As you can see there is just a label in the alertView, so you can create you own label and make it at the contentView at alertView with - (id)initWithTitle:(NSString *)title contentView:(UIView *)contentView cancelButtonTitle:(NSString *)cancelButtonTitle;

larryonoff commented 9 years ago

Good point. My assumptions is that since the method initWithTitle:message:cancelButtonTitle: is a part of the CXAlertView. It would be complete to have customisation as a part of the CXAlertView.

ChrisXu commented 9 years ago

Um. Actually the whole concept of this component is to allow anyone to add custom view on the alertView, thus I won't add features for that in case of losing the basic principle.

larryonoff commented 9 years ago

Up to you.

By the way initWithTitle:message:cancelButtonTitle: uses private method heightWithText:font. So h file doesn't describe available API entirely. So the control can be used properly only after analysis of m file.