[英]how do i achieve this in TableViewCell
see below figure, it has- TableView & tablecell have same background image ietableview & tablecell must not look different. 参见下图,它具有-TableView和tablecell具有相同的背景图像,即tableview和tablecell的外观必须相同。 in tableCell there must be one button .
在tableCell中必须有一个按钮。
To achieve this you'll have to create a customized UITableViewCell. 为此,您必须创建一个自定义的UITableViewCell。
You'll required 4 background image for your cell. 您需要为单元格提供4张背景图片。
a. 一种。 Image Facing right.
图像朝右。 b.
b。 Rollover image facing right.
翻转图像朝右。 c.
C。 Image Facing left.
图像朝左。 d.
d。 Rollover image facing left.
翻转图像朝左。
You'll have to set alternate image to your cell. 您必须为您的单元格设置备用图片。 And when you click on the cell you'll need to change the background image of that particular cell to Rollover image.
当您单击该单元格时,需要将该特定单元格的背景图像更改为“翻转图像”。 Also you'll have to manage the frames of your rest of the control accordingly.
另外,您还必须相应地管理其余控件的框架。
This is nothing but the image. 这不过是图像。 You have to set an image in every tableviewcell by passing the condition
您必须通过传递条件在每个tableviewcell中设置图像
if(indexpath.row/2 == 0)
<set_image1>
else
<set_image2>
then adjust other parameters according to your desired frame position. 然后根据所需的帧位置调整其他参数。
Note: You need to use dynamic tableviewcell height & You need for images for this.Two when cell is not selected & rest two when cell got selected 注意:您需要使用动态tableviewcell高度&为此需要图像。未选择单元格时两个,选择单元格时休息两个
Enjoy Programming! 享受编程!
I did this following way: I created two prototype cells having different Cell identifier eg left cell identifier= Cell1 & right cell identifier=Cell2. 我按照以下方式进行操作:我创建了两个具有不同单元标识符的原型单元,例如,左单元标识符= Cell1,右单元标识符= Cell2。
simply put one round-rect button, make it as custom because it shows only in image shape made table cell background color as clearColor, it requires because for the feel of table cell & tableview must look same. 只需放置一个圆角矩形按钮,使其自定义即可,因为它仅以图像形状显示,使表格单元格背景色为clearColor,这需要这样做,因为表格单元格和tableview的外观必须相同。
also set tableView background color as clearColor & add images to both button. 还将tableView的背景色设置为clearColor并将图像添加到两个按钮。
if ((indexPath.row)%2!=0)
{
CellIdentifier=@"Cell1";
}
else
{
CellIdentifier=@"Cell2";
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIButton *topicButton=(UIButton *)[cell viewWithTag:1];
NSString *topicNameLabel=[_topics objectAtIndex:indexPath.row];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.