Closed augustosamame closed 8 years ago
Hey @augustosamame, the start_spinner
and stop_spinner
animations are built into RMQ as conveniences. I'd recommend creating your own view with the spinner in it so that you have an actual reference to the spinner object and then you can just do something like find(:my_spinner_object).get.color = UIColor.greenColor
.
Thanks. I did the following and it's working perfectly:
class CustomSpinner
def start_spinner(style = UIActivityIndicatorViewStyleGray, opts = {})
spinner = self.window_spinner({ style: style }.merge(opts))
spinner.startAnimating
end
def stop_spinner
spinner = self.window_spinner
spinner.stopAnimating
end
protected
def window_spinner(opts={})
@_window_spinner ||= begin
parent = opts.fetch(:parent, app.window)
UIActivityIndicatorView.alloc.initWithActivityIndicatorStyle(opts.fetch(:style, UIActivityIndicatorViewStyleGray)).tap do |o|
o.hidesWhenStopped = true
o.color = UIColor.blueColor
o.transform = CGAffineTransformMakeScale(1.5, 1.5)
o.center = opts.fetch(:center, app.window.center)
o.layer.zPosition = NSIntegerMax
parent.addSubview(o)
end
end
end
end
Each time I need to show my custom (big and blue) spinner I just do:
custom_spinner = CustomSpinner.new
custom_spinner.start_spinner
.
.
.
custom_spinner.stop_spinner
Awesome! Glad you were able to figure it out!
Hi. I would like to change the RMQ spinner animation's color.
I have suceeded in changing between the 3 standard iOS spinner styles by calling:
rmq.animations.start_spinner(style = UIActivityIndicatorViewStyleWhiteLarge, opts = {})
but I don't know how to change the color to a darker color (my background is white so gray and white spinners are not being seen)
According to the iOS documentation, you can change it by setting:
aiv.color = [UIColor greenColor]
where
aiv
is theUIActivityIndicator
instance.but I have no idea how to implement this in RMQ / Rubymotion