我使用带有透明背景的collectionView和CollectionView下的imageView。我根据中间的单元格更改了ImageView,但是图像显示不正确,如何解决它,它应该如何看起来如下所示
的Gif:
它应该如何运作:
它如何运作:
SELECT cntry.cod_country
, rg.nom_region
, SUM(tr.unite) as [sum units M09]
, SUM(tr1.unite) as [sum units M10]
FROM [Backup].[dbo].[transac_EUR_M09_17] as tr
INNER JOIN [Backup].[dbo].[transac_EUR_M10_17] AS tr1 ON tr1.[cod_country] = tr.[cod_country]
AND tr1.[cod_region] = tr.[cod_region]
INNER JOIN [Backup].[dbo].[COUNTRY] as cntry ON tr.[cod_country] = cntry.[cod_country]
INNER JOIN [Backup].[dbo].Region as rg ON rg.[cod_country] = cntry.[cod_country]
AND rg.[cod_region] = tr.[cod_region]
Group BY cntry.cod_country, rg.nom_region
ORDER BY SUM(tr.unite), SUM(tr1.unite) DESC
CollectionViewCell
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionViewRecomend.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as? CustomPagerViewCell
let m = modals[indexPath.item]
cell?.ImageView.image = m.image
cell?.ImageView.backgroundColor = .white
cell?.Name.text = m.name
cell?.descriptions.text = m.description
cell?.Folowers.text = String(m.folower)
cell?.Publish.text = String(m.publish)
ImageSlider.image = modals[indexPath.row].image
cell?.liking = { (cells) in
if cell?.like.tintColor == UIColor(hex: 0xD1D1D1, alpha: 1) {
cell?.like.tintColor = UIColor.orange
self.favorite(cell: cell ?? UITableViewCell())
} else {
cell?.like.tintColor = UIColor(hex: 0xD1D1D1, alpha: 1)
self.favorite(cell: cell ?? UITableViewCell())
}
}
return cell!
}
insetForSectionAt
class CustomPagerViewCell: UICollectionViewCell {
@IBOutlet weak var ImageView: UIImageView!
@IBOutlet weak var Name: UILabel!
@IBOutlet weak var descriptions: UILabel!
@IBOutlet weak var Publish: UILabel!
@IBOutlet weak var Folowers: UILabel!
@IBOutlet weak var BG: UIView!
@IBOutlet weak var like: UIButton!
@objc var liking: ((UICollectionViewCell) -> Void)?
@IBAction func like(_ sender: Any) {
liking?(self)
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
like.tintColor = UIColor(hex: 0xD1D1D1, alpha: 1)
ImageView.contentMode = .scaleAspectFit
ImageView.layer.cornerRadius = 35
ImageView.layer.borderWidth = 1
ImageView.layer.borderColor = UIColor(hex: 0xD4D4D4, alpha: 1).cgColor
ImageView.layer.masksToBounds = true
}
CollectionViewFlowLayout
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
let cellWidth : CGFloat = self.collectionViewMenu.frame.width/1.2
let numberOfCells = floor(self.view.frame.size.width / cellWidth)
let edgeInsets = (self.view.frame.size.width - (numberOfCells * cellWidth)) / (numberOfCells + 1)
return UIEdgeInsetsMake(collectionViewRecomend.frame.height - 165, edgeInsets, 0, edgeInsets)
}