我希望我的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) 我正在使用带有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)
图片工厂 …