How do you change the shape of the imageview to hug your image?

Discussion in 'iOS Programming' started by Programmingling, Jun 21, 2010.

  1. Programmingling macrumors newbie

    Joined:
    Jun 21, 2010
    #1
    Here's the problem, with making a CGRect it just shows up as a rectangle and if I put a circular image inside it, or any oddly shaped image inside it and I want to click the image, the user can still just click in the square area of the cgrect instead of actually clicking the image.

    How do I either make it so that the image itself has to be clicked or the imageview is hugged onto the image so it's not a rectangle anymore?

    Also what does CG stand for anyway? :D
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    CG stands for CoreGraphics. I am struggling to understand exactly what you are trying to do. All views are rectangular. There is no way round that. If you have an image with transparency (not that all images are also rectangular) and you want the non-transparent section to not be touchable I suspect you are going to have to subclass UIImageView and implement your own hit-test unless there is an obvious, documented method that you should be using.
     
  3. Programmingling thread starter macrumors newbie

    Joined:
    Jun 21, 2010
    #3
    oh I'm sorry I probably did make this a bit more confusing than it should have been. The idea is

    let's say I have an image of a circle. I put it in a rectangular imageview box. How do I make it so that only the circle can be touchable and not the rest of the space inside the rectangle. I think you may have understood what I meant but I just want to check back with you.


    edit: yeah now that I read back and understood your post I think we're on the same page here. Can you say that again in a different wording? ( i meant the part where you say subclass and hit test stuff, i don't get what you mean ).
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    No, not really. That is the only way to say it. If you don't understand subclass you need to stop programming and go learn the basics of Object-Oriented Programming.

    Given that UIView has a method with the word hittest in the name I suggest you also learn to use the documentation.
     

Share This Page