cell最右邊顯示箭頭,字符,自定義分割線

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{   
         if (indexPath.section == 0) {      
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableViewCell];        
         if (indexPath.row == 0) {            
               cell.textLabel.text = @"新浪微博"; //cell的text內(nèi)容           
               UIView *lbl = [[UIView alloc] init]; //定義一個label用于顯示cell之間的分割線(未使用系統(tǒng)自帶的分割線),也可以用view來畫分割線            
               lbl.frame = CGRectMake(cell.frame.origin.x + 10, cell.frame.size.height - 5, cell.frame.size.width - 20, 1);            
               lbl.backgroundColor =  [UIColor lightGrayColor];          
               [cell.contentView addSubview:lbl];      
            }       
               UILabel *label = [[UILabel alloc] init]; //定義一個在cell最右邊顯示的label        
               label.text = @"Dark0921";       
               label.font = [UIFont boldSystemFontOfSize:14];
               [label sizeToFit];     
               label.backgroundColor = [UIColor clearColor];
               label.frame =CGRectMake(375 -label.frame.size.width - 10, 12, label.frame.size.width, label.frame.size.height);  
                [cell.contentView addSubview:label];       
                label.backgroundColor = [UIColor clearColor]; 
                label.textColor = [UIColor grayColor];      
                return cell; 
            }  else{        
                UITableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:kTableViewCell1];
                cell1.accessoryType = UITableViewCellAccessoryDisclosureIndicator; //顯示最右邊的箭頭        
                cell1.textLabel.text = @"添加好友";        
                return cell1;    
     }
}

實現(xiàn)后的效果:

屏幕快照 2015-12-22 下午2.12.26.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容