Sometimes, we maybe build some views repeatedly. Because we think that they just will be used under a condition. It's the curse of breaking the rule: DRY. In fact, If we are conscious of view's reusing, we will make more efforts to make it completely independent.
So for recording my growth, for writing less codes, for better tomorrow......
I should create this repository to summary some UI(cocoa Touch) extensions that are likely to be used in our work.
- Set image alignment:
button.zon.setImage(image, imageAlignment:.top, spacing:0, state:.normal)Effect just like this:
- Generate QR code:
QRImageView.image =UIImage.zon.qrImage(content:"我(I) you 🤣", size:CGSize(width:200, height:200))- Rotate image with degree by clockwise.
- Compose image with color.
- Tint image with color.
- Read gif file.
- Save image of UIImageView to album by Photos:
imageView.zon.saveImage(completion:@escaping(Result<UIImage,Error>)-> Void)- Edit action:
myLabel.zon.asMenuTrigger([MenuItem(title:"test", action: #selector(testAction))])- Get view controller who contains itself by response chain.
- Shortcuts of frame.
- Hotspot. Expand or shrink user interaction area with AOP.
letbutton=UIButton()
// Expand(negative value) or shrink(positive value) extra hotspot area.
button.zon.extraArea =.init(top:10, left:10, bottom:10, right:10)
// Specify minimum positive hotspot size. View will expand its bounds for Hit-Test equally to fit it.
button.zon.minimumSize =.init(width:44, height:44)- Add gradient layer:
letview=UIView()letlayer= view.zon.gradientLayer // GradationSettable, view will add sublayer automatically.
protocolGradationSettable:AnyObject{varlocations:[CGFloat]{getset}varcolors:[UIColor]{getset}varstartPoint:CGPoint{getset}varendPoint:CGPoint{getset}}- Add touchUpInside event action like UIButton with highlighted status:
view.zon.onTouchUpInside(canceller:OutOfBoundsCanceller()){
// do something.
}- The time interval of browsing view:
scene.zon.enableDurationTrack()
scene.zon.duration- Add/Remove child.
- Get a visiable navigation controller can push and pop view controller.
- Get/Set sring/image from background queue.
- Remove all arranged views.
- Set layout padding and background color.
- Reuse
- Scroll to bottom.
- Reuse
- Scroll to bottom.
- Init color with hex string like: prefix -> #/0x, suffix -> RGB/RGBA/RRGGBB/RRGGBBAA.
To be continue...




