Closed andrewhavens closed 9 years ago
Hey bud! Sugarcube is friendly but always a bit thick for a single need. Have you considered looking into https://github.com/skellock/motion-mastr ?
ALSO, it looks to me like you're trying to concat a non-attributed string to an attributed string. I don't think you can do that. If you switch it to just this, does it still error?:
class MyStylesheet < ApplicationStylesheet
def sign_in_text(st)
# ...
st.attributed_text = 'Sign In'.bold
end
end
Ah, you're totally right. I misread the error. The first string is trying to call .to_s
in order to concatenate it. I read the docs more closely and it explains that the first string needs to be an attributed string. I ended up with:
st.attributed_text = 'Already have an account? '.attrd + 'Sign In'.bold
awesome!
@GantMan Thanks again for letting me know about motion-mastr
. It wasn't long before I found myself limited by sugarcube's API. I soon switched to motion-mastr
and now my code is much more concise and readable:
# sugarcube:
attributed_text = 'Already have an account? '.attrd + 'Sign In'.nsattributedstring(NSFontAttributeName => font.bold_extra_small)
# motion-mastr
attributed_text = mastr('Already have an account? ').add('Sign In', font: font.bold_extra_small).build
\o/
It's a great library @skellock
I'm using sugarcube to create an attributed string that I am trying to apply to a UILabel using an RMQ stylesheet in a RedPotion project:
...but I'm getting this error:
Am I doing something wrong? Or is this a bug in RMQ or Sugarcube?