如何使用swift在IOS中实现marquee标签 [英] how to implement marquee label in IOS using swift

查看:237
本文介绍了如何使用swift在IOS中实现marquee标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在iOS中实施 MarqueeLabel 。我在Objective-C中找到了示例,但我使用的是Swift。

How to implement MarqueeLabel in iOS. I found example in Objective-C but I'm using Swift.

推荐答案

用于在swift中创建选取框在项目中添加以下类
https://github.com/cbpowell/MarqueeLabel-Swift/blob/master/Classes/MarqueeLabel.swift

For creating marquee in swift Add Below Class in your Project https://github.com/cbpowell/MarqueeLabel-Swift/blob/master/Classes/MarqueeLabel.swift

创建MaqQueeLabel类在您的类中添加以下内容。
创建一个标签和自定义类作为故事板中的MarqueeLabel
然后
@IBOutlet weak var marqueeLabel:MarqueeLabel!

Create MaqQueeLabel Class add the following in your class. Create one label And custom class as MarqueeLabel in storyboard Then @IBOutlet weak var marqueeLabel:MarqueeLabel!

在ViewDidLoad $ b中$ b add this

In ViewDidLoad add this

    marqueeLabel.type = .Continuous
    marqueeLabel.scrollDuration = 5.0
    marqueeLabel.animationCurve = .EaseInOut
    marqueeLabel.fadeLength = 10.0
    marqueeLabel.leadingBuffer = 30.0
    marqueeLabel.trailingBuffer = 20.0

这篇关于如何使用swift在IOS中实现marquee标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆