iOS開發,UIView中間如何切乙個透明的圓形出來

時間 2021-05-30 16:42:23

1樓:tabttoo

- (UIImage *)getImage{

UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, NO, 1.0);

CGContextRef con = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(con, [UIColor lightGrayColor].CGColor);//背景色

CGContextFillRect(con, [UIScreen mainScreen].bounds);

CGContextAddEllipseInRect(con, CGRectMake(50, 100, 200, 200));

CGContextSetBlendMode(con, kCGBlendModeClear);

CGContextFillPath(con);

UIImage *ima = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return ima;

- (void)addImage{

UIImageView *imageV = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];

imageV.image = [self getImage];

imageV.alpha = 0.5;

[self.view addSubview:imageV];

2樓:林魚禾

self.layer.cornerRadius = self.frame.size.width / 2;

self.clipsToBounds= YES;

self.backgroundColor = [UIColor clearColor];

self 為你要切的那個檢視。。。

2021 年,如何學習 iOS 開發?

iOSer搬磚猿 有經驗的iOS程式設計師如何提公升自己?工欲善其事,必先利其器。每個開發者都應該有一把自己的瑞士軍刀,在將來漫長的職業生涯中,這些工具可以為你省下寶貴的時間,並幫助你更好的組織個人知識庫。舉兩個例子 一套高效的開發環境 乙個資訊採集器和一本筆記本 我們可以從編緝器談起,這裡有IDE...

iOS遊戲開發流程?

以下就是晚上失眠了,想到哪寫到哪,所以很亂 做3d手遊還是建議用U3d。不過其實cocos2d x也是可以做3d手遊的,免費而且開源。只是,cocos2d x的3d部分不夠完善。去年大概11月份的時候我就碰到個坑,它竟然沒有獲得點沿過點的射線到平面距離的函式 缺少這個基本的函式就直接導致了,如果空間...

iOS 開發怎麼入門?

IOS開發新手入門經典指南 王者打靶 小遊戲 讓IOS應用支援橫屏 新增其他控制項 Label Button Slider 如何更新滑動條的值到對話方塊中 如何使用viewDidLoad 按照從上到下的順序閱讀。pan.baidu.com s 1o7PkQfS 密碼 0na2 Origheart 題...