自定义tablecell

<p class="p1"><span class="s1">UIButton</span><span class="s2"> *btnPoi = [[</span><span class="s1">UIButton</span><span class="s2"> </span>alloc<span class="s2">] </span>initWithFrame<span class="s2">:</span>CGRectMake<span class="s2">(</span><span class="s3">0</span><span class="s2">, </span><span class="s3">20</span><span class="s2">, </span><span class="s3">30</span><span class="s2">, </span><span class="s3">44</span><span class="s2">)];</span></p> <p class="p1"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[btnPoi </span>setBackgroundImage<span class="s2">:[</span><span class="s1">UIImage</span><span class="s2"> </span>imageNamed<span class="s2">:</span><span class="s4">@"poi.png"</span><span class="s2">] </span>forState<span class="s2">:</span>UIControlStateNormal<span class="s2">];</span></p> <p class="p2">             [cell.<span class="s1">contentView</span> <span class="s5">addSubview</span>:btnPoi];</p> <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p> <p class="p1"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s1">UILabel</span><span class="s2">* lb=[[</span><span class="s1">UILabel</span><span class="s2"> </span>alloc<span class="s2">] </span>initWithFrame<span class="s2">:</span>CGRectMake<span class="s2">(</span><span class="s3">30</span><span class="s2">, </span><span class="s3">20</span><span class="s2">, </span><span class="s3">50</span><span class="s2">, </span><span class="s3">44</span><span class="s2">)];</span></p> <p class="p4"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>lb.</span>numberOfLines<span class="s2">=</span><span class="s3">0</span><span class="s2">;</span></p> <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>lb.<span class="s1">text</span>=<span class="s4">@"</span><span class="s6">位置</span><span class="s4">:"</span>;</p> <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>lb.<span class="s1">tag</span>=<span class="s3">1</span>;</p> <p class="p4"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>lb.</span>backgroundColor<span class="s2">=[</span>UIColor<span class="s2"> </span><span class="s5">clearColor</span><span class="s2">];</span></p> <p class="p5"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>lb.</span><span class="s1">font</span><span class="s2">=[</span><span class="s1">UIFont</span><span class="s2"> </span><span class="s5">fontWithName</span><span class="s2">:</span>@"Helvetica-Bold"<span class="s2"> </span><span class="s5">size</span><span class="s2">:</span><span class="s3">16</span><span class="s2">];</span></p> <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[cell.<span class="s1">contentView</span> <span class="s5">addSubview</span>:lb];</p> <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p> <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p> <p class="p1"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s1">UILabel</span><span class="s2">* lbl=[[</span><span class="s1">UILabel</span><span class="s2"> </span>alloc<span class="s2">] </span>initWithFrame<span class="s2">:</span>CGRectMake<span class="s2">(</span><span class="s3">80</span><span class="s2">, </span><span class="s3">0</span><span class="s2">, </span><span class="s3">220</span><span class="s2">, </span><span class="s3">100</span><span class="s2">)];</span></p> <p class="p4"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>lbl.</span>numberOfLines<span class="s2">=</span><span class="s3">0</span><span class="s2">;</span></p> <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>lbl.<span class="s1">text</span>=[<span class="s7">listData</span> <span class="s5">objectAtIndex</span>:indexPath.<span class="s5">section</span>];</p> <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>lbl.<span class="s1">tag</span>=<span class="s3">1</span>;</p> <p class="p4"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>lbl.</span>backgroundColor<span class="s2">=[</span>UIColor<span class="s2"> </span><span class="s5">clearColor</span><span class="s2">];</span></p> <p class="p5"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>lbl.</span><span class="s1">font</span><span class="s2">=[</span><span class="s1">UIFont</span><span class="s2"> </span><span class="s5">fontWithName</span><span class="s2">:</span>@"Helvetica-Bold"<span class="s2"> </span><span class="s5">size</span><span class="s2">:</span><span class="s3">16</span><span class="s2">];</span></p> <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[cell.<span class="s1">contentView</span> <span class="s5">addSubview</span>:lbl];</p><p/>

posted on 2011-08-02 17:13  风乔  阅读(49)  评论(0编辑  收藏  举报

导航