statusBar状态栏消息滚动显示控件

利用状态栏来提示和显示状态,字数太多可以滚动显示完之后消失

- (void)showWithStatus:(NSString *)status barColor:(UIColor*)barColor textColor:(UIColor*)textColor{
if (_isshowing) {
    return;
}
_isshowing = YES;
if(!self.superview)
    [self.overlayWindow addSubview:self];
[self.overlayWindow setHidden:NO];
[self.topBar setHidden:NO];
self.topBar.backgroundColor = barColor;
NSString *labelText = status;
CGRect labelRect = CGRectZero;
CGFloat stringWidth = 0;
CGFloat stringHeight = 0;
if(labelText) {
    CGSize size = [labelText boundingRectWithSize:CGSizeMake((self.topBar.frame.size.width-20), 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.label4Title.font} context:nil].size;
    stringWidth = size.width;
    stringHeight = size.height;
    _timeInterval4Label = stringHeight/10;
    labelRect = CGRectMake(10, 0, stringWidth, stringHeight);
}
self.label4Title.frame = labelRect;
self.topBar.contentSize = CGSizeMake(self.topBar.frame.size.width, labelRect.size.height+20);
self.label4Title.alpha = 0.0;
self.label4Title.hidden = NO;
self.label4Title.text = labelText;
self.label4Title.textColor = textColor;
[UIView animateWithDuration:0.4 animations:^{
    self.label4Title.alpha = 1.0;
}];
[UIView animateWithDuration:0.4 animations:^{
    self.label4Title.alpha = 1.0;
} completion:^(BOOL finished) {
    [self beginScrollWithTimeOfTimer:_timeInterval4Label];
}];
[self setNeedsDisplay];}

使用起来相当简单 [WHPStatusBar showSuccessWithStatus:@”显示消息”];这一句就好

源码地址下载github