IPhone: How do you clip/mask a UIView?

I need to mask a UIView (add rounded corners etc) but can't seem to work out how.
On the desktop i'd look at adding a mask to the CALayer but it seems the iPhone SDK excludes the functionality.
Any ideas on how I can achieve the result?
p.s. I have no control over the content being rendered in the view (user submitted images)
Cheers

OK, I get it now. One way I can think of is to build your view as you do now with square corners but don't add to the parent view yet. Then you can create a graphics context and setup a clipping region in the new context with round corners. Then you can draw your view into this context. Then extract an image from the context. Now you use this image to display to the user instead of the original view you created behind the scenes.
Here's code I used to convert an arbitrary view into an image. All you need to do is add the clipping code to create the rounded corners.
- (UIImage *)convertView:(UIView *)view {
UIGraphicsBeginImageContext(view.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
// Clear whole thing
CGContextClearRect(ctx, view.bounds);
// Add your code to create rounded rectangle clipping region
// Draw view into context
[view.layer renderInContext:ctx];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;

Similar Messages

  • HT4191 iPhone Local Storage "My iPhone" - How do you create this folder for use by the Notes app on a iPhone or iPad?  If I want to keep some notes only on my device and not in a cloud environment associated with an e-mail account.

    iPhone Local Storage "My iPhone" - How do you create this folder for use by the Notes app on a iPhone or iPad?  If I want to keep some notes only on my device and not in a cloud environment associated with an e-mail account.  I've seen reference to the  "My iPhone" local storage put no mention on how you create this folder or access this folder within the Notes app.  I realize storing information in a local storage like this provides no syncing between other iDevices but that is exactly what I'm looking for.  I'm running iOS7.0.4 on a iPhone 5S, and a iPad Air.  Any help would be greatly appreciated.

    If you go to Settings > Notes > Default Account you will see "On My iPhone" as the default account and the only choice if you have not enabled syncing Notes in Settings >iCloud or Settings > Mail, Contacts, Calendars. If you have enabled syncing you can still select "On My iPhone" as the default account. When you are in the Notes app you won't see any accounts listed if you have not enabled syncing because they are all in the On My iPhone account and that is the only place possible. It is not a folder that you create.

  • If you deleted a  device off of find my iphone.how do you get the device to start back up agian and put it back on find my iphone?

    if you deleted a  device off of find my iphone.how do you get the device to start back up agian and put it back on find my iphone? becuase i have delted my dads iphone acedentily of find my iphone and it is nownot working. his phone is just staying at a black screen with a loading circle on it. i need to know how to fix this..like do i go the to apple store or the carrier store or can i fix it at home?

    Try these two ways to fix the iPhone (in order).  If neither works, you would have to take it to the store.
    1.  Reset the iPhone.  Hold the on/off and home buttons togehter for about 10 seconds.  If it works, you'll get the Apple logo and then something good should happen.
    2.  Try recovery mode as described here:
    http://support.apple.com/kb/HT1808
    If one of these work, you can then re-introduce the iPhone to Find My iPhone by doing Settings > iCloud > Find My iPhone = "On" on the device.

  • HT6058 Hello I installed the 7.0.5 version iPhone 5c and it canceled the Hayiklod sharing photos between iPhone iPhone how can you fix it

    Hello I installed the 7.0.5 version iPhone 5c and it canceled the Hayiklod sharing photos between iPhone iPhone how can you fix it

    I'm guessing extremely botched translation of "iCloud", based on the phonetics.

  • How to create Clipping Masks with Shapes and Text?

    Hi there! I am new to Illustrator and am currently attempting to learn it. I am creating a logo that has text and has a shape that goes through the text to make the text appear as if it has claw marks in it.
    I have two layers. The layer with the shape "claw" marks, and a layer with the text. The shape layer is currently above and the text layer is currently below. If I select both layers and click on Make Clipping Mask it has the text displayed within the little claw marks, how do I reverse that? Because when I try to change the order of the layers it doesn't clip anything?
    Thank you so much!
    Aaron

    Hi Monika,
    Sorry for taking so long to reply... This is what I am trying to accomplish. I tried following your directions above, but that only made the text invisible and I tried moving the claw layers above and below the text... and it only appeared as if the claws per se were filling up with the text color.
    Here is what I am trying to accomplish:

  • How do you permanently delete apps from all your mac products (MacBook Pro, iPad, iPhone), how do you permanently delete apps from all your mac products (MacBook Pro, iPad, iPhone)

    how do you permanently delete apps from all your mac products (MacBook Pro, iPad, iPhone)

    They are not taking up storage space.  Apple knows you installed them at one time (="purchased", whether you paid money or not), and merely keeps a list so that if you wish to reinstall any of them on this or a future device, you can.  This is useful if maybe you deleted them due to space constraints, and now have a device with more memory and wish to reinstall.
    It's also useful for taking a trip down Memory Lane looking at all the useless apps you installed once then immediately deleted once you realized they were total garbage ...

  • I have 2 iphones, how do you sync them on computer

    How do you sync 2 different Iphones on the same computer? I have a 5c and my husband has a 4, after i synced my phone and was going to do my hussbands since I deleted and set up new Icloud account for his phone it would keep everything seperate. Not as soon as I plugged his in computer it change where my phone was to his. Will this make my phone lose all it contents, pics, and apps if i go ahead and sync his phone?

    McCarty20 wrote:
    Will this make my phone lose all it contents, pics, and apps if i go ahead and sync his phone?
    no, syncing with itunes works one way, from the itunes to the devices. so whatever is on the itunes and selected to sync over is what will sync onto ur device.

  • How do you like the iPhone, How do you like the iPhone

    How do you like the iPhone?

    Contact the original cellular provider, as they are the only ones that can provide unlocking.

  • How to make clipping mask with text and vector pattern?

    Hey there guys, any help would be greatly appreciated. Im making a logo for a client and am having a nightmare of a time trying to properly use the clipping masks in illustrator CS5. I copied and pasted the  logo I made behind itself with a different color just for a drop shadow-like effect. And now I'm trying to apply this diagonal line pattern I created over top the "shadow" I made to give it some texture.
    Here's an example of what I'm going for, only imagine the line pattern on the text instead of banner

    Eric,
    As I (mis)understand it, you can either keep the Type live (or outline it) and:
    1) Create one copy of the pattern for each Type object (this will give you the opportunity of having different(ly coloured) patterns;
    2) For each Type object, select the type object and one of the patterns and Object>Clipping Path>Make;
    or you can:
    1) Select both Type objects and Type>Create Outlines, then Object>Compound Path>Make;
    2) Select the compound object and the pattern and Object>Clipping Path>Make.

  • Hi! How to remove clipping mask in multiplу boxes on page?

    I need to remove more than 300 clipping masks that created in InDesign Clipping Path by Detect Edges
    Will be glad any advice for decreasing time of this process ))

    You can script it. This AppleScript (OSX only) would remove all of the clipping paths in the active document:
    tell application "Adobe InDesign CC 2014"
        set clipping type of clipping path of all graphics of active document to none
    end tell

  • I had an iphone 3GS, but received my new iPhone 5 with micro sim, but wanted to keep old mobile number so rang up to change it, that's all working fine, but iMessage is still using the number I received with iPhone, how do you delete a new number?

    I had an iphone 3GS (normal sim), but received my new iPhone 5 with micro sim, but wanted to keep old mobile number so rang up to change it, normal text messaging is working fine, but iMessage is still using the number I received with iPhone 5, how do you delete that number I can only receive iMessages on my original number?

    Issue solved

  • HT1807 In a foreign country you buy a card for air time, on the iphone how do you know how much time is left.

    In a foreign country Panama, you buy air time so much at a time with a time card.  How do you tell how much time is left on the iphone?

    Depends on the carrier you are using the card with, They will have special # codes or a number to call

  • How do you delete movies from your iPhone, How do you delete movies from your iPhone

    How can you delete movies and tv shoes from your iPhone with the iOS 7

    Please read this article how to delete movies from your iphone.
    http://support.apple.com/kb/PH3304

  • I just switched to android but am still getting texts on my old apple iPhone- how do you fix?

    I just switched to android but am still getting texts on my old apple iPhone- how do I fix?

    Try this....
    http://support.apple.com/kb/ts5185
    Ian

  • Itunes and iphone: how do you separate music and video on the purchase list

    Hi, I buy my music and video on itunes and synchronise it with my iphone. When listening to the music from the iphone, the videos are unfortunately mixed with the music, which does not make any sense: it should be dispatched in two different play list. The playlist I use is called "purchases" but I don't have any "only music" play list. When I go to the Iphone parameters, I have not selected the function "include de video clips", so why are they mixed???

    From the description you gave you were treating recent purchases as a play list (It can be but as you discovered it's not the best use for it.)and that's what was causing the problem.
    Most of us can't get all our music, not to mention videos, into an iPhone so we create play list so we can sync to them.
    Set up a few for practice, say 25 songs each, and see how that works for you.
    Or try the "Genius" feature.
    Once you get the hang of it you can create your own mixes for all moods and occasions.
    Tired of a play list? Delete it, it won't harm your library, and create another.
    Do the same with your videos, only selected one are to be synced.
    You haven't been making full use of your iTunes/iPhones set up.
    Go here and get the manual : http://support.apple.com/manuals/

Maybe you are looking for

  • Accruals Condition Record posted late in COPA along with the Settlement

    Hi Gurus, Accruals condition record for 1 item in an Invoice is posted along with the Settlement Credit Note in COPA. While condition records of the other items from the same invoice were posted on the Billing Date itself. For eg: Invoice 111       D

  • SAP router error on windows server 2008 64bit

    Hi All, I am installing sap router on windows 2008 server 64 bit. While trying to generate certificate request it showing below error. E:\usr\sap\saprouter\nt-x86_64>sapgenpse get_pse -v -r certreq -p local.pse "CN= solman, OU=000XXXXXXX, OU=SAProute

  • Error MEPO000

    Hi friends , When i am saving the PO , the system showing error message " Purchase order still contains faulty items Message no. MEPO000" , so what should be the problem . When give tax code in invoice tab then only it appear . Please reply , Raghu

  • Idocs are failing

    Hi, We have a Z program which creates Inbound idocs by processing the files at the application layer. Once the idoc is procesed, based on our business requirement we split the parent idoc into more than one idoc with different message type and proces

  • Reimport model

    Hi, I was wondering how ABAP WebDynpro handles model changes? In Java WD, you can do something called "Reimport model", which will then regenerate the context nodes for import and export and the java representing classes of ABAP objects/ddic structur