shadow method error

Discussion in 'iOS Programming' started by anuroop, May 22, 2009.

  1. anuroop macrumors newbie

    Joined:
    Mar 26, 2009
    #1
    hi all,
    i m using a function in my project as written below to make shadow effect on the text drawn:

    CGContextSetShadowWithColor(context, CGSizeMake(2, -2), 1, CGColorGetConstantColor(kCGColorBlack));


    but it gives warning in 2.2.1 sdk that "kCGColorBlack" is unavailable and if i compile my project in 3.0 it gives error showing same thing.

    if there is anybody to tell me the alternate of kCGColorBlack then i'll be very thankfull to him.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    I'm not sure why this is.

    In the header it's defined as:
    Code:
    CG_EXTERN CGColorRef CGColorGetConstantColor(CFStringRef colorName)
        CG_AVAILABLE_STARTING(__MAC_10_5, [B]__IPHONE_2_0[/B]);
    But kCGColorBlack is defined as:
    Code:
    CG_EXTERN const CFStringRef kCGColorBlack
        CG_AVAILABLE_STARTING(__MAC_10_5, [b]__IPHONE_NA[/b]);
    Why would they define the function but not let you use the constants? :confused:
     
  3. bed macrumors member

    Joined:
    May 26, 2008
    #3
    kCGColorBlack is just a CFStringRef constant.

    You can still use CGColorGetConstantColor, like so:

    NSString* blackString = [NSString stringWithString:mad:"kCGColorBlack"];
    CGColorGetConstantColor((CFStringRef)blackString);
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    Try

    Code:
    [UIColor blackColor].CGColor
    I don't know why that string constant is __IPHONE_NA but it is so it's not available.
     

Share This Page