gpt4 book ai didi

ios - 如何将图像添加到 ios 中 uicollectionView 单元格的左上角?

转载 作者:技术小花猫 更新时间:2023-10-29 11:04:37 26 4
gpt4 key购买 nike

我想在 UICollectionViewCell 的左上角添加按钮。我可以在单元格的左上角添加按钮,但它不会出现在单元格的顶部,而是出现在单元格的下方。请告诉我该怎么做?

我正在使用以下代码:
enter image description here

_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];

编辑:
我想做这样的删除图标:
enter image description here

最佳答案

您是否尝试将其添加到单元格的内容 View 中?[cell.contentView addSubview:_deleteButton];

关于ios - 如何将图像添加到 ios 中 uicollectionView 单元格的左上角?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33580589/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com