• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iOS: String Drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iOS: String Drawing


  • Subject: Re: iOS: String Drawing
  • From: Development <email@hidden>
  • Date: Tue, 12 Jul 2011 08:27:46 -0700

Ok… Thank you very much both of you, I missed radius and opacity. Those were the two things I wanted which I was using my code to get

On Jul 12, 2011, at 6:36 AM, Jeff Kelley wrote:

> To echo Graham’s point, you can also use the CALayer of the label and modify
> its properties to get a more customized appearance. You’ve got shadowColor,
> shadowOffset, shadowOpacity, shadowPath, and shadowRadius. Between those
> properties and the label’s built-in shadow support, there’s a lot of
> customization to be had.
>
> Jeff Kelley
>
>
> On Tue, Jul 12, 2011 at 6:22 AM, Graham Cox <email@hidden> wrote:
>
>> AFAIK, you don't have to subclass UILabel - it has a shadowColor/offset
>> property that you can set as you wish, and it should all "just work". Sure,
>> the default values are sometimes a bit questionable, but all you need to do
>> is to set those shadow properties in IB or in code.
>>
>> You're doing way too much work, and breaking something in the process. I
>> don't see anything in your code that adds anything to what you can do with
>> the view's standard properties. Also, I found that things such as shadow
>> blur radius aren't necessarily well supported in iOS, which probably doesn't
>> have the processing power to do that very well - even on Mac shadows kill
>> performance.
>>
>> --Graham
>>
>>
>> On 12/07/2011, at 4:49 PM, Development wrote:
>>
>>> Among the myriad of problems I'm having with this application a new one
>> developed when I began adding a shadow to text.
>>> The default text shadows look terrible on iPhone. This I subclassed
>> UILabel and did an override of drawTextInRect
>>>
>>> Well in order to draw with the correct colors I have had to do all my
>> custom stuff and then call [super drawTextInRect:rect];
>>>
>>> It all works until an Italic font is used. Then the last maybe 5 pixel
>> are cut out of the text. I've attempted to adjust both the bounding box of
>> the parent view and the subclassed label both, and it does not seem to
>> change the views at all. So I'm not entirely sure how but I'm screwing up
>> adjusting a rectangle… (Hoiw hard is it to add 6 pixels to width of a darn
>> rect?)
>>> Anyway. So I attempted to use a string drawing method, which would among
>> other things allow me to set the alignment. This works, until I click the
>> text (which selects it) And it also fails to draw in the correct color.
>> (Always black instead of whatever it should be)
>>>
>>> Is string drawing possible if I want color? I need to override to get
>> nice shadows but it creates this nightmare.
>>>
>>>   CGSize myShadowOffset = self.offset;
>>>   float myColorValues[] = {0, 0, 0, self.depth};
>>>
>>>   CGContextRef myContext = UIGraphicsGetCurrentContext();
>>>   CGContextSaveGState(myContext);
>>>
>>>   CGColorSpaceRef myColorSpace = CGColorSpaceCreateDeviceRGB();
>>>   CGColorRef myColor = CGColorCreate(myColorSpace, myColorValues);
>>>   CGContextSetShadowWithColor (myContext, myShadowOffset, self.spread,
>> myColor);
>>>
>>>   CGSize newSize = rect.size;
>>>   CGSize imgSize = [self.text sizeWithFont:self.font];
>>>   imgSize.width +=6; //this does nothing
>>>      //everything below adjusts for the shadow which is a flipping train
>> wreck of its own.
>>>      CGPoint  p;
>>>      CGFloat x=0.0,y=spread;
>>>
>>>   if (myShadowOffset.width <=0) {
>>>       x =((newSize.width -
>> (imgSize.width+(spread*2)))/2)+abs(myShadowOffset.width);
>>>   }
>>>      else if(myShadowOffset.width >0){
>>>              x =0;
>>>      }
>>>      p = CGPointMake(x, y);
>>>
>>>   rect.origin = p;
>>>   rect.size = imgSize;
>>>
>>>   [super drawTextInRect:rect];
>>>
>>>   CGColorRelease(myColor);
>>>   CGColorSpaceRelease(myColorSpace);
>>>
>>>   CGContextRestoreGState(myContext);
>>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >iOS: String Drawing (From: Development <email@hidden>)
 >Re: iOS: String Drawing (From: Graham Cox <email@hidden>)
 >Re: iOS: String Drawing (From: Jeff Kelley <email@hidden>)

  • Prev by Date: Re: iOS: String Drawing
  • Next by Date: Re: Adding Spotlight comment data to folder/file
  • Previous by thread: Re: iOS: String Drawing
  • Next by thread: Re: iOS: String Drawing
  • Index(es):
    • Date
    • Thread