NSArray * nib = [[NSBundle mainBundle] loadNibNamed:@"DishDetailTopView" owner:self options:nil]; DishDetailTopView * view = [nib objectAtIndex:0];//通过nib文件生成的view view.backgroundColor = [UIColor orangeColor]; [_scrollView addSubview:view];