「ios」UISearchBarの背景色を設定するコード

iosコード:
cftSearchBar.backgroundColor = RGBACOLOR(249,249,249,1);
cftSearchBar.backgroundImage = [self imageWithColor:[UIColor clearColor] size:cftSearchBar.bounds.size];

//earchbarの背景色をキャンセル
– (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
{
CGRect rect = CGRectMake(0, 0, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return image;
}

Comments are closed.