Code Monkey home page Code Monkey logo

fastickers's Introduction

FAStickers

CI Status Version License Platform

ColorfulTornJunco-small

Features

  • Supports Stickers
  • Supports Emojis
  • Supports Gifs
  • Swift 5

Requirements

  • iOS 11.0 and later
  • swift 5

Installation

FAStickers is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'FAStickers'

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

import FAStickers
import UIKit
class ViewController: UIViewController{

var StickerVC: StickerViewController!
public var stickers : [String] = []
public var gifs : [String] = []



override func viewDidLoad() {
super.viewDidLoad()

// append stickers
for i in 100...110 {
stickers.append(i.description)
}


let gifImage = ["gif1","gif2","gif3","gif4", "gif5","gif6","gif7","gif8", "gif9"]
// append gitf
for i in gifImage {
gifs.append(i)
}

StickerVC = StickerViewController(nibName: nil, bundle: Bundle(for: StickerViewController.self))


}

@IBAction func AddSticker(_ sender: Any) {
showStickerView()
}



}


extension ViewController: StickerEmojiDelegate {


func GitTapped(GifName: String) {
print(GifName)
let Gif = UIImageView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
Gif.loadGif(name: GifName)
Gif.contentMode = .scaleAspectFit
Gif.center = view.center
self.view.addSubview(Gif)

self.removeStickerView()
}


func EmojiTapped(EmojiName: String) {
print(EmojiName)
var emojiView = UIView()
let emojiLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 70, height: 70))
emojiLabel.text = EmojiName
emojiLabel.font = UIFont.systemFont(ofSize: 50)
emojiView = emojiLabel
emojiView.center = view.center
self.view.addSubview(emojiView)
self.removeStickerView()
}

func StickerTapped(StickerName: String) {
print(StickerName)
let Sticker = UIImageView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
Sticker.image = UIImage(named: StickerName)
Sticker.contentMode = .scaleAspectFit
Sticker.center = view.center
self.view.addSubview(Sticker)

self.removeStickerView()
}



func showStickerView() {

StickerVC.stickerDelegate = self


// append gifs
for gifImage in self.gifs {
StickerVC.gits.append(gifImage)
}

// append stickers
for stickersImage in self.stickers {
StickerVC.stickers.append(stickersImage)
}

self.addChild(StickerVC)
self.view.addSubview(StickerVC.view)
StickerVC.didMove(toParent: self)
let height = view.frame.height
let width  = view.frame.width
StickerVC.view.frame = CGRect(x: 0, y: self.view.frame.maxY , width: width, height: height)
}

func removeStickerView() {
UIView.animate(withDuration: 0.3,
delay: 0,
options: UIView.AnimationOptions.curveEaseIn,
animations: { () -> Void in
var frame = self.StickerVC.view.frame
frame.origin.y = UIScreen.main.bounds.maxY
self.StickerVC.view.frame = frame

}, completion: { (finished) -> Void in
self.StickerVC.view.removeFromSuperview()
self.StickerVC.removeFromParent()
})
}

}

Delegate:

StickerEmojiDelegate
func EmojiTapped(EmojiName: String)
func StickerTapped(StickerName: String)
func GitTapped(GifName: String)

Author

Faris Albalawi, [email protected]

License

FAStickers is available under the MIT license. See the LICENSE file for more info.

fastickers's People

Contributors

farisalbalawi avatar

Stargazers

Husnain Ali avatar MohsinAli avatar

Watchers

MohsinAli avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.