Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

Reasons

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.

Usage

UIButtom + ImageAlignment

The code like this:

button.setImage(image, imageAlignment: .top, spacing: 0, state: .normal)

Effect just like this:

bottom image left margin image right margin image top image

UIImage + QRCodeImage

A sample class func:

QRImageView.image = UIImage.qrImage(content: "我(I) you 🤣", size: CGSize(width: 200, height: 200))

The QR code image as follows:

QR code image

UIImageView + SaveImage

In some cases, we need to save image to local. for example, user avatar, qr code......

UIImageWriteToSavedPhotosAlbum can help us finish it simply. But there is a point should be noticed: get current context graphics image and then save. You can use it like this under this extension:

imageView.saveImage(finishedHandler: ((UIImage) -> Void)? = nil, failedHandler: ((Error) -> Void)? = nil)

UIView + MenuTrigger

We need edit function, we need edit function, we need edit function, so:

myLabel.asMenuTrigger([MenuItem(title: "test", action: #selector(testAction))])

UIImageView and UILabel contain default copy action.

To be continue...

About

some sample tools about cocoa touch

Topics

Resources

Releases

No releases published

Packages

No packages published

Languages