现在的位置: 首页 > 综合 > 正文

UIToolBar 背景图片设置

2017年12月09日 ⁄ 综合 ⁄ 共 426字 ⁄ 字号 评论关闭
    UIToolbar *toolBar = [[[UIToolbar alloc]initWithFrame:CGRectMake(0, self.scrollView.frame.size.height, self.view.frame.size.width, 30)] autorelease];
    
    UIImage *root_image = [UIImage imageNamed:@"toolbarBackground.png"];
    
    if ([toolBar respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)]) {
        [toolBar setBackgroundImage:root_image forToolbarPosition:0 barMetrics:0];         //仅5.0以上版本适用
    }else{
        toolBar.barStyle = UIToolbarPositionTop;
    }

抱歉!评论已关闭.