小编use*_*658的帖子

快速背景色动画循环

我希望我的iOS应用程序的背景颜色在x秒内在四种颜色之间切换

这就是我到目前为止(当我只指定2种颜色时,它正是我想要的)

我还需要动画无限循环运行.

ViewController.swift

    UIView.animateWithDuration(X.0, animations: {
        // Color 1
        self.view.backgroundColor = UIColor(rgba)
        // Color 2
        self.view.backgroundColor = UIColor(rgba)
        // Color 3
        self.view.backgroundColor = UIColor(rgba)
        // Color 4
        self.view.backgroundColor = UIColor(rgba)

    })
Run Code Online (Sandbox Code Playgroud)

animation loops colors ios swift

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

FactoryGirl .update实际上不会更新关联的对象

我正在使用带有FactoryGirl的Rails 4.1.7,Rspec 3.0.4和一个Postgresql ActiveRecord数据库。

我正在尝试测试一种找到关联模型的方法,然后更新该模型中的列。在这一点上,测试还很粗糙,但它使所有关联成为必要(我在撬动中检查)。调用该方法时,期望值将继续返回nil(默认情况下该列为nil,但应更新为日期时间)。下面是代码:

post_picture_spec.rb

require 'rails_helper'

RSpec.describe ModelName::PostPicture, :type => :model do

  describe 'update_campaign method' do

    context 'when the picture is tied to a campaign' do

      before do
        @campaign = FactoryGirl.create(:campaign)
        @campaign.media << @picture1 = FactoryGirl.create(:picture, posted: true, time_scheduled: Date.parse('2014-07-15 18:00:00'), time_posted: Date.parse('2014-07-15 18:00:00'))
        @campaign.media << @picture2 = FactoryGirl.create(:picture, posted: true, time_scheduled: Date.parse('2014-08-20 19:00:00'), time_posted: Date.parse('2014-08-20 19:00:00'))
      end

      it 'should update first item in campaign' do
        # pending("FactoryGirl update issue")
        ModelName::PostPicture.send(:update_campaign, @picture)
        expect(@campaign.time_started).to eq(@picture.time_posted)
      end

  end

end
Run Code Online (Sandbox Code Playgroud)

图片工厂 …

postgresql rspec ruby-on-rails factory-bot

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

标签 统计

animation ×1

colors ×1

factory-bot ×1

ios ×1

loops ×1

postgresql ×1

rspec ×1

ruby-on-rails ×1

swift ×1