我想在 UICollectionViewCell
的左上角添加按钮。我可以在单元格的左上角添加按钮,但它不会出现在单元格的顶部,而是出现在单元格的下方。请告诉我该怎么做?
_deleteButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, delButtonSize, delButtonSize)];
_deleteButton.center = CGPointMake(9, 10);
_deleteButton.backgroundColor = [UIColor clearColor];
[_deleteButton setImage: [UIImage imageNamed:@"cross_30.png"] forState:UIControlStateNormal];
[cell addSubview:_deleteButton];
[_deleteButton addTarget:self action:@selector(deleteRecipe:) forControlEvents:UIControlEventTouchUpInside];
最佳答案
您是否尝试将其添加到单元格的内容 View 中?
[cell.contentView addSubview:_deleteButton];
关于ios - 如何将图像添加到 ios 中 uicollectionView 单元格的左上角?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33580589/