Git Product home page Git Product logo

pkcslice's Introduction

PKCSlice

Version License Platform Swift 4.0

Introduce

The view can be slanted and added dynamically. You may or may not fill the top and bottom views.

demo demo2

Requirements

PKCSlice written in Swift 4. Compatible with iOS 8.0+

Installation

Cocoapods

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

pod 'PKCSlice'

Usage

Xib or Storyboard file

setting

image

image

view

image

done!




Code editor

import PKCSlice
let sliceView = PKCSlice()
self.view.addSubview(sliceView)

AutoLayout Example

sliceView.translatesAutoresizingMaskIntoConstraints = false
self.view.addConstraint(NSLayoutConstraint(
  item: self.view,
  attribute: .leading,
  relatedBy: .equal,
  toItem: sliceView,
  attribute: .leading,
  multiplier: 1,
  constant: 0)
)
self.view.addConstraint(NSLayoutConstraint(
  item: self.view,
  attribute: .trailing,
  relatedBy: .equal,
  toItem: sliceView,
  attribute: .trailing,
  multiplier: 1,
  constant: 0)
)
self.view.addConstraint(NSLayoutConstraint(
  item: self.view,
  attribute: .top,
  relatedBy: .equal,
  toItem: sliceView,
  attribute: .top,
  multiplier: 1,
  constant: 0)
)
self.view.addConstraint(NSLayoutConstraint(
  item: self.view,
  attribute: .bottom,
  relatedBy: .equal,
  toItem: sliceView,
  attribute: .bottom,
  multiplier: 1,
  constant: 0)
)

done!




Property

inclination

sliceView.inclination = 100

sliceView

// Returned as an array of PKCSliceView
sliceView.sliceViewArray//get-only

// Make Array in colors
sliceView.hexColors = "e2e2e2,000000"

// SliceView Fill top
sliceView.isTopFill = true

// SliceView Fill bottom
sliceView.isBottomFill = true

// topSliceView
sliceView.topSliceView = PKCSliceView()

// bottomSliceView
sliceView.bottomSliceView = PKCSliceView()

// Make Simply topSliceView
sliceView.topHexColor = "e2e2e2"

// Make Simply bottomSliceView
sliceView.bottomHexColor = "e2e2e2"



Method

append

sliceView.append(PKCSliceView())
sliceView.append(contentsOf: [PKCSliceView(), PKCSliceView()])

remove

sliceView.removeAll()

redraw

// ReDraw
sliceView.redraw()



Delegate

class ViewController: UIViewController{
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let sliceView = PKCSlice()
        sliceView.delegate = self
    }
}

extension ViewController: SliceViewDelegate{

    // sliceView Touch
    func sliceTouchAction(_ slice: PKCSlice, sliceView: PKCSliceView, index: Int) {
    
    }
    
    // sliceTopView Touch
    func sliceTopTouchAction(_ slice: PKCSlice, sliceView: PKCSliceView) {
    
    }
    
    // sliceBottomView Touch
    func sliceBottomTouchAction(_ slice: PKCSlice, sliceView: PKCSliceView) {
    
    }
}



Customize

PKCSliceView Customize

MAKE CustomSliceView.xib &

import UIKit
import PKCSlice

class CustomSliceView: PKCSliceView {
    @IBOutlet private weak var imageView1: UIImageView!
    @IBOutlet private weak var imageView2: UIImageView!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.imageView1.contentMode = .scaleAspectFill
        self.imageView2.contentMode = .scaleAspectFill
        self.imageView1.clipsToBounds = true
        self.imageView2.clipsToBounds = true
        self.imageView1.image = UIImage(named: "1.png")
        self.imageView2.image = UIImage(named: "2.png")
    }
}
guard let sliceView = Bundle.main.loadNibNamed("CustomSliceView", owner: self, options: nil)?.first as? CustomSliceView else{ return }
self.sliceView.append(sliceView)

Author

pikachu987, [email protected]

License

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

pkcslice's People

Contributors

pikachu987 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pkcslice's Issues

Use of undeclared type 'PKCSliceDelegate'

Swift 4.2
Xcode 10.0

import UIKit
import PKCSlice
class ViewController: UIViewController , PKCSliceDelegate{
    
    @IBOutlet var myview: UIView!
    @IBOutlet var mySliceView: UIView!
    override func viewDidLoad() {
        super.viewDidLoad()
    
        var views = [UIView]()
        views.append(myview)
        let view1 = UIView()
        views.append(view1)
        
        let sliceView = PKCSlice(self.mySliceView, views: views, inclination: -50)
        sliceView.delegate = self
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func pkcSliceTouch(_ index: Int) {
        print(index)
    }
}

screen shot 2018-11-23 at 5 49 57 pm

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.