<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://blog.visuaweb.com/index.php/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>VisuaBlog - UITable Font</title>
  <link>http://blog.visuaweb.com/index.php/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Mon, 15 Dec 2008 20:24:26 +0100</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Iphone Dev : Changer la font d'un UITableCell</title>
    <link>http://blog.visuaweb.com/index.php/post/2007/12/06/Modify-the-text-Font-of-a-UITableCell</link>
    <guid isPermaLink="false">urn:md5:1d0254ea5532592201c2bfd695190bba</guid>
    <pubDate>Thu, 06 Dec 2007 12:22:00 +0100</pubDate>
    <dc:creator>Jeremie Engel</dc:creator>
        <category>IPhone</category>
        <category>Iphone Source</category><category>UITable Font</category>    
    <description>    &lt;br /&gt;Vous développez une application IPhone qui utilise un tableau UITable pour afficher du texte et vous souhaitez changer la taille du texte ?&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;Voici une solution simple. Il s'agit d'ajouter à la vue de la cellule un objet UITextLabel dont la font sera modifiable.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;Dans l'exemple ci-dessous, la UITable créée contient 2 colonnes et 1 ligne dont la typo est Helvetica de taille 16.&lt;/div&gt;&lt;div&gt;&lt;div&gt;WebFontCache.h est a importer, il fait parti de WebKit.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;-(&lt;span style=&quot;color: #aa0d91&quot;&gt;void&lt;/span&gt;)showTable&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;{&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;UIView *v = [[[UIView alloc] initWithFrame: [window bounds]] autorelease];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;&lt;span style=&quot;color: #aa0d91&quot;&gt;float&lt;/span&gt; th = &lt;span style=&quot;color: #1c00cf&quot;&gt;115&lt;/span&gt;;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;CGSize vs = [v bounds].size;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;table = [[UITable alloc] initWithFrame: CGRectMake(&lt;span style=&quot;color: #1c00cf&quot;&gt;0&lt;/span&gt;,th,vs.width,vs.height-s.height-th)];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;[table addTableColumn: [[[UITableColumn alloc] initWithTitle:&lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;&quot;&lt;/span&gt; identifier:&lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;col1&quot;&lt;/span&gt; width:&lt;span style=&quot;color: #1c00cf&quot;&gt;220&lt;/span&gt;] autorelease]];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;[table addTableColumn: [[[UITableColumn alloc] initWithTitle:&lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;&quot;&lt;/span&gt; identifier:&lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;col2&quot;&lt;/span&gt; width:&lt;span style=&quot;color: #1c00cf&quot;&gt;100&lt;/span&gt;] autorelease]];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;[table setDataSource: &lt;span style=&quot;color: #aa0d91&quot;&gt;self&lt;/span&gt;];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;[v addSubview: table];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;[window setContentView: v];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;}&lt;/p&gt;
&lt;div&gt;&lt;div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;- (&lt;span style=&quot;color: #aa0d91&quot;&gt;int&lt;/span&gt;)numberOfRowsInTable:(UITable*)table&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;{&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91&quot;&gt;return&lt;span style=&quot;color: #000000&quot;&gt; &lt;/span&gt;&lt;span style=&quot;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(28, 0, 207);&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;}&lt;/p&gt;
&lt;div&gt;&lt;div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;- (UITableCell*)table:(UITable*)table cellForRow:(&lt;span style=&quot;color: #aa0d91&quot;&gt;int&lt;/span&gt;)row column:(UITableColumn *)column&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;{&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;&lt;span style=&quot;color: #aa0d91&quot;&gt;id&lt;/span&gt; cell = [[[UIImageAndTextTableCell alloc] init] autorelease];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;UITextLabel *textLabel = [UITextLabel alloc];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;&lt;span style=&quot;color: #aa0d91&quot;&gt;if&lt;/span&gt; ([column identifier] == &lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;col1&quot;&lt;/span&gt;) [textLabel initWithFrame:CGRectMake(&lt;span style=&quot;color: #1c00cf&quot;&gt;10.0f&lt;/span&gt;,&lt;span style=&quot;color: #1c00cf&quot;&gt;0.0f&lt;/span&gt;,&lt;span style=&quot;color: #1c00cf&quot;&gt;210.0f&lt;/span&gt;,&lt;span style=&quot;color: #1c00cf&quot;&gt;30.0f&lt;/span&gt;)];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;&lt;span style=&quot;color: #aa0d91&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #aa0d91&quot;&gt;if&lt;/span&gt; ([column identifier] == &lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;col2&quot;&lt;/span&gt;) [textLabel initWithFrame:CGRectMake(&lt;span style=&quot;color: #1c00cf&quot;&gt;0.0f&lt;/span&gt;,&lt;span style=&quot;color: #1c00cf&quot;&gt;0.0f&lt;/span&gt;,&lt;span style=&quot;color: #1c00cf&quot;&gt;100.0f&lt;/span&gt;,&lt;span style=&quot;color: #1c00cf&quot;&gt;30.0f&lt;/span&gt;)];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;&lt;span style=&quot;color: #aa0d91&quot;&gt;if&lt;/span&gt;( row == &lt;span style=&quot;color: #1c00cf&quot;&gt;0&lt;/span&gt; &amp;amp;&amp;amp; [column identifier] == &lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;col1&quot;&lt;/span&gt; )  [textLabel setText: &lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;text to print Col1&quot;&lt;/span&gt;];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;&lt;span style=&quot;color: #aa0d91&quot;&gt;if&lt;/span&gt;( row == &lt;span style=&quot;color: #1c00cf&quot;&gt;0&lt;/span&gt; &amp;amp;&amp;amp; [column identifier] == &lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;col2&quot;&lt;/span&gt; ) [textLabel setText: &lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;text to print Col2&quot;&lt;/span&gt;];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;// Modify the UITableCell Font with a subview UITextLabel&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;[textLabel setFont: [NSClassFromString(&lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;WebFontCache&quot;&lt;/span&gt;) createFontWithFamily:&lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;Helvetica&quot;&lt;/span&gt; traits:&lt;span style=&quot;color: #1c00cf&quot;&gt;2&lt;/span&gt; size:&lt;span style=&quot;color: #1c00cf&quot;&gt;16&lt;/span&gt;]];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;[textLabel setCentersHorizontally:&lt;span style=&quot;color: #aa0d91&quot;&gt;NO&lt;/span&gt;];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;[cell addSubview: textLabel];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;[textLabel release];&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;&lt;span style=&quot;color: #aa0d91&quot;&gt;return&lt;/span&gt; cell;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;}&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
    
    
    
          <comments>http://blog.visuaweb.com/index.php/post/2007/12/06/Modify-the-text-Font-of-a-UITableCell#comment-form</comments>
      <wfw:comment>http://blog.visuaweb.com/index.php/post/2007/12/06/Modify-the-text-Font-of-a-UITableCell#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.visuaweb.com/index.php/feed/rss2/comments/7</wfw:commentRss>
      </item>
    
</channel>
</rss>