小编D. *_*nna的帖子

快速循环进展

我正在尝试快速制作一个简单的圆形进度条。到目前为止我没有做的是,进度应该从圆的顶部开始(目前它从 90 度点开始)。我还想在进度线下方有一条圆形线,它应该比进度线粗并且颜色也不同。

任何人都可以让我朝着我的愿望走正确的方向吗?

这是我的功能:

func animateView() {

let circle = viewProgress // viewProgress is a UIView

        var progressCircle = CAShapeLayer()

        let circlePath = UIBezierPath(ovalInRect: circle.bounds)

        progressCircle = CAShapeLayer ()
        progressCircle.path = circlePath.CGPath
        progressCircle.strokeColor = UIColor.greenColor().CGColor
        progressCircle.fillColor = UIColor.clearColor().CGColor
        progressCircle.lineWidth = 5.0

        circle.layer.addSublayer(progressCircle)

        let animation = CABasicAnimation(keyPath: "strokeEnd")
        animation.fromValue = 0
        animation.toValue = 1.5
        animation.duration = 1
        animation.fillMode = kCAFillModeForwards
        animation.removedOnCompletion = false

        progressCircle.addAnimation(animation, forKey: "ani")
    }
Run Code Online (Sandbox Code Playgroud)

伊戈尔这是它的样子:

在此处输入图片说明

uiview ios progress-bar swift

5
推荐指数
1
解决办法
1万
查看次数

tableview单元格上的按钮不起作用 - 快速

我的自定义tableview单元格上有一个按钮,显示用户名称.
当你点击它时,你应该被带到他/她的个人资料但没有任何反应?

这是我的自定义tableview单元类(commentsTableViewCell.swift):

import UIKit

protocol commentsTableViewCellDelegate {
    func namesIsTapped(cell: commentsTableViewCell)
}


class commentsTableViewCell: UITableViewCell {

    @IBOutlet weak var nameButton: UIButton!
    @IBOutlet weak var commentLabel: UILabel!
    @IBOutlet weak var profilePic: UIImageView!
    @IBOutlet weak var dateLabel: UILabel!
    @IBOutlet weak var uidLabel: UILabel!

    var delegate: commentsTableViewCellDelegate?

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    @IBAction func nameIsTapped(sender: AnyObject) {
        //4. call delegate …
Run Code Online (Sandbox Code Playgroud)

uitableview custom-cell ios swift

1
推荐指数
1
解决办法
1976
查看次数

在同一uitableview中显示两个不同的自定义单元格-Swift Firebase

我目前在同一uitableview上显示两种不同类型的自定义单元格时遇到问题。

到目前为止,我管理的工作是接收对更新单元格的“更新” cell。我只是无法弄清楚如何也让numberOfRowsInSection返回两个值,所以我的两个单元格都将显示。

让我解释一下我的代码:

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return updates.count
        return updatesTask.count // I CANNOT DO THIS - what can I do instead?
    }



    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell:updateTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! updateTableViewCell
        let cellTask:tasksTableViewCell = tableView.dequeueReusableCellWithIdentifier("TaskCell", forIndexPath: indexPath) as! tasksTableViewCell


        let update = updates[indexPath.row]
        let updateTask = updatesTask[indexPath.row]


        // Example of the two …
Run Code Online (Sandbox Code Playgroud)

uitableview ios firebase swift

0
推荐指数
1
解决办法
1万
查看次数

CAShapeLayer 的位置不正确

我有一个UIViewviewProgress. 它是图像中的白框。我想要一个圆形的进度条,也就是图片中的绿色圆圈。进度条应该留在白框内,但正如您所看到的那样。

我如何让它留在里面viewProgress?在这里你有我的动画功能:

func animateView() {

        let circle = viewProgress // viewProgress is a UIView

        var progressCircle = CAShapeLayer()

        let circlePath = UIBezierPath(arcCenter: circle.center, radius: circle.bounds.midX, startAngle: -CGFloat(M_PI_2), endAngle: CGFloat(3.0 * M_PI_2), clockwise: true)

        progressCircle = CAShapeLayer ()
        progressCircle.path = circlePath.CGPath
        progressCircle.strokeColor = UIColor.whiteColor().CGColor
        progressCircle.fillColor = UIColor.clearColor().CGColor
        progressCircle.lineWidth = 10.0

        circle.layer.addSublayer(progressCircle)

        let animation = CABasicAnimation(keyPath: "strokeEnd")
        animation.fromValue = 0
        animation.toValue = 0.4
        animation.duration = 1
        animation.fillMode = kCAFillModeForwards
        animation.removedOnCompletion = false

        progressCircle.addAnimation(animation, forKey: "ani") …
Run Code Online (Sandbox Code Playgroud)

position cabasicanimation cashapelayer ios swift

0
推荐指数
1
解决办法
2907
查看次数