<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>backgroundColor &#8211; SMsoft &#8211; informatica e dintorni</title>
	<atom:link href="https://blog.smsoft.it/tag/backgroundcolor/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.smsoft.it</link>
	<description>consigli settimanali su MacOS, GNU/Linux ed Open Source</description>
	<lastBuildDate>Tue, 24 Apr 2012 09:08:56 +0000</lastBuildDate>
	<language>it-IT</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=84791</generator>
	<item>
		<title>Objective-c: Impostare il background color di UITableViewCell</title>
		<link>https://blog.smsoft.it/2012/04/24/objective-c-impostare-il-background-color-di-uitableviewcell/</link>
					<comments>https://blog.smsoft.it/2012/04/24/objective-c-impostare-il-background-color-di-uitableviewcell/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 24 Apr 2012 09:08:56 +0000</pubDate>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[backgroundColor]]></category>
		<category><![CDATA[cell]]></category>
		<category><![CDATA[UIColor]]></category>
		<category><![CDATA[UIImage]]></category>
		<category><![CDATA[UITableViewCell]]></category>
		<guid isPermaLink="false">http://blog.smsoft.it/?p=1752</guid>

					<description><![CDATA[Per impostare il colore di background di una UITableViewCell è possibile utilizzare diversi metodi, ma solo uno permette di colorare completamente l&#8217;intera cella (compreso il fondo delle scritte e degli eventuali accessori della cella stessa). Il seguente codice: [crayon-6a4204a21a060343808929/] inserito nel metodo &#8211; (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath, permette di colorare, a righe alterne, il ... <a title="Objective-c: Impostare il background color di UITableViewCell" class="read-more" href="https://blog.smsoft.it/2012/04/24/objective-c-impostare-il-background-color-di-uitableviewcell/" aria-label="Per saperne di più su Objective-c: Impostare il background color di UITableViewCell">Leggi tutto</a>]]></description>
										<content:encoded><![CDATA[<p>Per impostare il colore di background di una UITableViewCell è possibile utilizzare diversi metodi, ma solo uno permette di colorare completamente l&#8217;intera cella (compreso il fondo delle scritte e degli eventuali accessori della cella stessa).</p>
<p>Il seguente codice:</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">NSUInteger row = [indexPath row];
    if(row % 2){
        cell.backgroundColor = [UIColor whiteColor];
    }
    else{ 
        cell.backgroundColor =[[UIColor alloc] 
             initWithRed:((float)(222.0 / 255.0)) 
             green:((float)(227.0 / 255.0)) 
             blue:((float)(231.0 / 255.0)) alpha:1.0f];
    }</pre><p></p>
<p>inserito nel metodo <strong>&#8211; (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath</strong>, permette di colorare, a righe alterne, il fondo della cella di grigio.</p>
<p>Per usare invece un&#8217;immagine, es <strong>greyBarTC.png</strong>, che riempia completamente lo sfondo della cella, si può usare il codice:</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">cell.backgroundColor = [UIColor colorWithPatternImage:
       [UIImage imageNamed:@"greyBarTC.png"]];</pre><p></p>
<p>&nbsp;</p>
<p>In alcuni casi, purtroppo, questo non è sufficiente. Basterà allora creare il nuovo seguente metodo <strong>&#8211; (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath</strong>:</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger row = [indexPath row];
    if(row % 2){
       [cell setBackgroundColor:[UIColor whiteColor]];
    } else { 
       [cell setBackgroundColor:[[UIColor alloc] initWithRed:((float)(222.0 / 255.0)) green:((float)(227.0 / 255.0)) blue:((float)(231.0 / 255.0)) alpha:1.0f]];
    }
}</pre><p></p>
<p>enjoy!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.smsoft.it/2012/04/24/objective-c-impostare-il-background-color-di-uitableviewcell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
