Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


creating a uiimage from a uicolor to use as a background image for uibutton


creating a uiimage from a uicolor to use as a background image for uibutton  using -'I'm,creating,a,colored,image,like,this:

CGRect,rect,=,CGRectMake(0,,0,,1,,1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef,context,=,UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,[[UIColor,redColor],CGColor]);
//,,[[UIColor,colorWithRed:222./255,green:227./255,blue:,229./255,alpha:1],CGColor]),;
CGContextFillRect(context,,rect);
UIImage,*img,=,UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();


and,then,use,it,as,the,background,image,of,a,button:

[resultButton,setBackgroundImage:img,forState:UIControlStateNormal];


This,works,great,using,the,redColor,,however,I,want,to,use,an,RGB,color,(as,shown,in,the,commented,line).,When,I,use,the,RGB,color,,the,buttons,background,isn't,changed.

What,am,I,missing?'


    This question already has an answer here:
    
        
            How to create a colored 1x1 UIImage on the iPhone dynamically?
                
                    4 answers
                
        
    

asked Oct 13, 2015 by tushar2k6
0 votes
3 views



Related Hot Questions



Government Jobs Opening


...