alexaubry / alexaubry/BulletinBoard
Accessing the BLTNPageItem ImageView
- Langage dominant
- Swift
- Étoiles
- 5.3k
- Forks
- 301
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
### New Issue Checklist
- [x] I updated BulletinBoard to the latest version.
- [x] I read the [Contribution Guidelines](https://github.com/alexaubry/BulletinBoard/blob/master/CONTRIBUTING.md).
- [x] I read the [documentation](https://alexaubry.github.io/BulletinBoard).
- [x] I searched for [existing GitHub issues](https://github.com/alexaubry/BulletinBoard/issues).
### Issue Description
I would like to set an image **dynamically** with Kingfisher, but it appears that the imageView is read-only (and apparently set to `nil`). Is it possible to do this without subclassing BLTNItem?
### Environment
- **BulletinBoard Version**: v2 (CocoaPods)
- **iOS Version**: 11.4
- **Device(s)**: iPhone X
### Example
This is an example subclass that I could not get to work.
``` swift
class FriendRequestBulletin: BLTNPageItem {
var fromUserImageContainer = UIView()
var fromUserImageView = UIImageView()
func setFromUserImage(withURL url: URL) {
fromUserImageView.kf.setImage(with: url)
}
override func makeViewsUnderTitle(with interfaceBuilder: BLTNInterfaceBuilder) -> [UIView]? {
fromUserImageView = UIImageView(frame: CGRect(x: 50, y: 0, width: 200, height: 200))
fromUserImageView.layer.cornerRadius = 100
fromUserImageView.contentMode = .scaleAspectFill
fromUserImageView.clipsToBounds = true
fromUserImageContainer.addSubview(fromUserImageView)
fromUserImageContainer.heightAnchor.constraint(equalToConstant: 200.0).isActive = true
return [fromUserImageContainer]
}
}
```
Instantiating and displaying the above class:
``` swift
let example: URL = URL(string: " . . . ")!
let exampleBulletin = FriendRequestBulletin(title: "Friend Request")
// Prep bulletin
exampleBulletin.isDismissable = false
exampleBulletin.descriptionText = "USER NAME wants to be your friend."
exampleBulletin.actionButtonTitle = "Accept"
exampleBulletin.alternativeButtonTitle = "Ignore"
exampleBulletin.setFromUserImage(withURL: example)
// Show bulletin
let manager: BLTNItemManager = BLTNItemManager(rootItem: exampleBulletin)
manager.showBulletin(above: self)
```
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.