Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] failed on set font/titleColor for UIButton #110

Open
anguskwan opened this issue Aug 2, 2013 · 3 comments
Open

[HELP] failed on set font/titleColor for UIButton #110

anguskwan opened this issue Aug 2, 2013 · 3 comments

Comments

@anguskwan
Copy link

  style :clickme,
        origin: [10, 10], extends: :rounded_button,
        title: "Click Me!"

  style :rounded_button,
        width: 300,
        height: 50,
        #font: "Helvetica".uifont(20),
        #titleColor: "#FFFFFF".uicolor,
        backgroundColor: UIColor.tealColor,
        layer: {
            #shadowColor: "#c6c6c6".uicolor,
            shadowOpacity: 0.5,
            shadowOffset: CGSizeMake(2.0, 4.0),
            shadowRadius: 3.0,
            masksToBounds: false,
            cornerRadius: 8
        },
        clipsToBounds: true

image

  1. if i set font on, the shadow will disappear ... why?
  2. how to set titleColor、shadowPath accurately?something like the code in https://github.com/bennyguitar/Colours-for-iOS/blob/master/ColoursDemo/ColoursDemo/ViewController.m

thank you :)

@colinta
Copy link
Owner

colinta commented Aug 2, 2013

I'll try to duplicate this, could you create a small project that includes this code? It would help me fix it faster if I could clone a project and get it working (plus that way I know that the code reproduces the bug)

@anguskwan
Copy link
Author

i am using ProMotion with TeaCup, the main code is:

  1. app_delegate.rb
class AppDelegate < PM::Delegate

  def on_load(app, options)
    open ArticleScreen.new(nav_bar: true)
    #open Colours.new
  end
end
  1. colours_screen.rb
class Colours < PM::Screen

  stylesheet :about

  layout :root do
    @scroll = subview(UIScrollView, :content) do
      @btn1 = subview(UIButton.custom, :clickme)
      subview(UILabel, :title)
      subview(UILabel, :about)
      subview(UIView, :line)
    end
  end

  def on_load

  end

end
  1. colours_style.rb
# -*- encoding : utf-8 -*-
Teacup::Stylesheet.new(:about) do
  style :root,
        backgroundColor: UIColor.whiteColor

  style :content,
        constraints: [:top, :full],
        backgroundColor: UIColor.whiteColor

  style :clickme,
        origin: [10, 10], extends: :rounded_button,
        title: "Click Me!"

  style :title,
        constraints: [:full_width, constrain_below(:clickme, 10), :center_x, constrain_height(30)],
        font: 'Cassannet Regular'.uifont(20),
        textAlignment: UITextAlignmentCenter,
        numberOfLines: 1,
        text: '-------------------------------'

  style :about,
        constraints: [constrain_width(220), constrain_below(:title, 40), :center_x, constrain_height(200)],
        font: 'Arvo'.uifont(11),
        textAlignment: UITextAlignmentCenter,
        numberOfLines: 0,
        text: "trying teacup to styling app"


  style :line,
        constraints: [constrain_below(:about, 10), constrain_size(220, 1), :center_x],
        backgroundColor: '#c6c6c6'.uicolor


  style :rounded_button,
        width: 300,
        height: 50,
        #font: "Helvetica".uifont(20),
        #titleColor: "#FFFFFF".uicolor,
        backgroundColor: UIColor.tealColor,
        layer: {
            #shadowColor: "#c6c6c6".uicolor,
            shadowOpacity: 0.5,
            shadowOffset: CGSizeMake(2.0, 4.0),
            shadowRadius: 3.0,
            masksToBounds: false,
            cornerRadius: 8
        },
        clipsToBounds: true
end

can this help ?

@colinta
Copy link
Owner

colinta commented Mar 19, 2014

Hi, I was not able to reproduce your project (a repo that I can clone would be best, I have very limited time to investigate these issues).

At the least, I think the shadowColor should be a CGColor. e.g. shadowColor: '#c6c6c6'.uicolor.cgcolor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants