Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mpramodjain

macrumors regular
Original poster
Nov 20, 2008
152
0
Banglore
Can it be possible to draw the rounded rectangle with colored corner without using stroke and clipping concept?
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
Import "QuartzCore", and add
Code:
object.layer.cornerradius = 15.0;

about the color, i'll leave the searching for you ;)
i'll give you some hints.
Also Quartzcore & here are some hints
Code:
    object.layer.borderWidth = 2.0;
    CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB();
    CGFloat values[4] = {1.0, 1.0, 1.0, 0.3}; 
    CGColorRef white = CGColorCreate(rgbColorspace, values);

Now you need to assign this to your object (the color) and release the colors, cuz it's leaking right now ;) have fun.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Code:
    CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB();
    CGFloat values[4] = {1.0, 1.0, 1.0, 0.3}; 
    CGColorRef white = CGColorCreate(rgbColorspace, values);

Here's a one-liner alternative to generating CGColor:
Code:
CGColorRef white = [[UIColor colorWithWhite:1.0 alpha:0.3] CGColor];
 

North Bronson

macrumors 6502
Oct 31, 2007
395
1
San José
Import "QuartzCore", and add
Code:
object.layer.cornerradius = 15.0;

This works, and if drawing a rounded-rectangle with Quartz is not an option for some reason, this can be used. However, doing this kind of work with Core-Animation properties introduces performance hits because of some subtle compositing and rendering issues. In many cases, you will have better performance if you just use Quartz and draw the border directly in a custom view.
 

mpramodjain

macrumors regular
Original poster
Nov 20, 2008
152
0
Banglore
Thanks for all your replies.

What I observed is, going with layer property change, will draw the colored border (line) over the subviews also.

For eg : if we draw a UIView (with rounded layer cornered, using layer property and larger width) , with a subview of text box. Then the border gets drawn over the textbox view also.

If I go with some coregraphics (i tried using stroke and clipping previous), found the border doesn't gets override.

So what I am trying is , draw rounded, colored border for an UIView with following are my points to consider :

i) without using clipping and stroking , as it will clip the other part of the bordered stroke.
ii) without modifying internal layer of the view object, as it will override the colored border on the internal successive subviews if the border width exceeds for some reason (change in design)..

Trying using insets for the multiple rectangles and changing the color .. the other way around.. will update..
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.