美文网首页工作生活
FSPageControl的几种用法

FSPageControl的几种用法

作者: Boxzhi | 来源:发表于2019-07-01 10:02 被阅读0次
  • 选中为椭圆,非选中为圆,切宽度不一样

    image.png
bannerControl = FSPageControl(frame: CGRect.zero)
bannerControl?.numberOfPages = 2
bannerControl?.contentHorizontalAlignment = .center
bannerControl?.contentInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
bannerControl?.setStrokeColor(UIColor(r: 117, g: 223, b: 172), for: .normal)
bannerControl?.setStrokeColor(.white, for: .selected)
bannerControl?.setFillColor(UIColor(r: 117, g: 223, b: 172), for: .normal)
bannerControl?.setFillColor(.white, for: .selected)
bannerControl?.interitemSpacing = 10
bannerControl?.setPath(UIBezierPath(roundedRect: CGRect(x: bannerControl!.itemSpacing / 2 - 6, y: 0, w: 12, h: 4), cornerRadius: 2), for: .selected)
bannerControl?.setPath(UIBezierPath(ovalIn: CGRect(x: bannerControl!.itemSpacing / 2 - 2, y: 0, w: 4, h: 4)), for: .normal)

  • 选中非选中都为椭圆、宽高一样

    image.png
 let _pageControl = FSPageControl(frame: CGRect.zero)
_pageControl.numberOfPages = vcType.pageNumber
_pageControl.contentHorizontalAlignment = .left
_pageControl.contentInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0)
_pageControl.setStrokeColor(UIColor(r: 236, g: 237, b: 241), for: .normal)
_pageControl.setStrokeColor(UIColor(r: 160, g: 165, b: 187), for: .selected)
_pageControl.setFillColor(UIColor(r: 236, g: 237, b: 241), for: .normal)
_pageControl.setFillColor(UIColor(r: 160, g: 165, b: 187), for: .selected)
_pageControl.interitemSpacing = 20
_pageControl.setPath(UIBezierPath(roundedRect: CGRect(x: 0, y: 0, w: 20, h: 3), cornerRadius: 1.5), for: .selected)
_pageControl.setPath(UIBezierPath(roundedRect: CGRect(x: 0, y: 0, w: 20, h: 3), cornerRadius: 1.5), for: .normal)

  • 五角星⭐️

    image.png
 fileprivate var starPath: UIBezierPath {
        let width = self.pageControl.itemSpacing
        let height = self.pageControl.itemSpacing
        let starPath = UIBezierPath()
        starPath.move(to: CGPoint(x: width*0.5, y: 0))
        starPath.addLine(to: CGPoint(x: width*0.677, y: height*0.257))
        starPath.addLine(to: CGPoint(x: width*0.975, y: height*0.345))
        starPath.addLine(to: CGPoint(x: width*0.785, y: height*0.593))
        starPath.addLine(to: CGPoint(x: width*0.794, y: height*0.905))
        starPath.addLine(to: CGPoint(x: width*0.5, y: height*0.8))
        starPath.addLine(to: CGPoint(x: width*0.206, y: height*0.905))
        starPath.addLine(to: CGPoint(x: width*0.215, y: height*0.593))
        starPath.addLine(to: CGPoint(x: width*0.025, y: height*0.345))
        starPath.addLine(to: CGPoint(x: width*0.323, y: height*0.257))
        starPath.close()
        return starPath
    }

  • 爱心❤️

    image.png
 fileprivate var heartPath: UIBezierPath {
        let width = self.pageControl.itemSpacing
        let height = self.pageControl.itemSpacing
        let heartPath = UIBezierPath()
        heartPath.move(to: CGPoint(x: width*0.5, y: height))
        heartPath.addCurve(
            to: CGPoint(x: 0, y: height*0.25),
            controlPoint1: CGPoint(x: width*0.5, y: height*0.75) ,
            controlPoint2: CGPoint(x: 0, y: height*0.5)
        )
        heartPath.addArc(
            withCenter: CGPoint(x: width*0.25,y: height*0.25),
            radius: width * 0.25,
            startAngle: .pi,
            endAngle: 0,
            clockwise: true
        )
        heartPath.addArc(
            withCenter: CGPoint(x: width*0.75, y: height*0.25),
            radius: width * 0.25,
            startAngle: .pi,
            endAngle: 0,
            clockwise: true
        )
        heartPath.addCurve(
            to: CGPoint(x: width*0.5, y: height),
            controlPoint1: CGPoint(x: width, y: height*0.5),
            controlPoint2: CGPoint(x: width*0.5, y: height*0.75)
        )
        heartPath.close()
        return heartPath
    }

相关文章

  • FSPageControl的几种用法

    选中为椭圆,非选中为圆,切宽度不一样image.png 选中非选中都为椭圆、宽高一样image.png 五角星⭐️...

  • 箭头函数

    这个是几种用法分为为是否有参数的

  • look的几种用法

    look for 寻找 1.A:What are you looking for?你在找什么呢?B:I am lo...

  • WebView的几种用法

    // 取消右侧,下侧滚动条,去处上下滚动边界的黑色背景 _webView.delegate=self; _webV...

  • header 的几种用法

    1. 跳转页面 2. 声明content-type 3. 返回response状态码 4. 在某个时间后执行跳转 ...

  • MJExtension的几种用法

    这次研究下MJExtension,MJExtension是解析json的三方框架,简单实用下面是几种用法 最简单的...

  • swal的几种用法

    1,弹出提示框,点击确认,进行下一步操作 2,仅弹出提示框 3,仅弹出提示框,简单写法

  • Promise的几种用法

    Promise 1、什么是Promise ? 在ES6中一个非常重要和好用的特性就是Promise但是在初次接触P...

  • TabLayout 的几种用法

    1.结合ViewPager使用 这是最常见的用法了,实现也比较简单。 布局文件: 对应的Activity页面: 设...

  • iconfont的几种用法

    在日常的开发学习中 ,我们常常为字体图标而犯难,尤其对新手来说,下面介绍几种icon的用法,以阿里的iconfon...

网友评论

    本文标题:FSPageControl的几种用法

    本文链接:https://www.haomeiwen.com/subject/efvwcctx.html