Invalid context when creating UIImageView

前端 未结 4 1555
甜味超标
甜味超标 2021-02-05 23:06

I have an error when I tried to create a UIImageView. Look at this code :

UIImage* backgroundPanel = [[UIImage imageNamed:@\"loginPanelBackground.png\"] resizabl         


        
相关标签:
4条回答
  • 2021-02-05 23:19

    The Simulator is case-insensitive. The device is case-sensitive. The png is named correctly? Maybe it is 'Login' with a capital L.

    0 讨论(0)
  • 2021-02-05 23:20

    I still can't comment due to low rep. However I'd like to add to neon1's answer which helped me a lot.

    You also need to make sure that all of the insets are greater than zero.

    insets.left > 0

    insets.top > 0

    insets.right > 0

    insets.bottom > 0

    0 讨论(0)
  • 2021-02-05 23:24

    See the answer here : How do I capture UIImage of complete contents of UITableView / UIScrollView and make it work on an ios device

    Thanks eliajf !

    0 讨论(0)
  • 2021-02-05 23:40

    I had this problem until I found out that my cap inset argument to resizableImageWithCapInsets: was wrong — it didn't leave any un-capped area at all (you need at least 1x1 pixel not covered by a cap). So make sure that:

    (insets.left + insets.right) < width

    and

    (insets.top + insets.bottom) < height

    0 讨论(0)
提交回复
热议问题