You can use this code for hyperlinked button as well as underlined text . You  know there is no facilities for such option in none of iPhone SDK. So you can try this. It works for me.

in .h file

@interface UnderLineLabel : UIButton{
CGFloat stockWidth;

}

@property(nonatomic,assign)CGFloat stockWidth;

@end

in .m file

@implementation UnderLineLabel

@synthesize stockWidth;

- (id)initWithFrame:(CGRect)frame {

if (self = [super initWithFrame:frame]) {

// Initialization code

}

return self;

}

- (void)drawRect:(CGRect)rect {

[super drawRect:rect];

CGContextRef context = UIGraphicsGetCurrentContext();

CGFloat components[4] = {0.654901961, 0.662745098, 0.674509804, 1};

CGContextSetStrokeColor(context, components);

// Draw them with a 1.0 stroke width.

CGContextSetLineWidth(context, self.stockWidth);

// Draw a single line from left to right

CGContextMoveToPoint(context, 0, rect.size.height);

CGContextAddLineToPoint(context, rect.size.width, rect.size.height); 

CGContextStrokePath(context);

}

- (void)dealloc {

[super dealloc]; 

}

@end
Advertisement
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.