如何使UIView的背景透明化,以便用户可以看到其(模糊的)主屏幕?
如果这不可能,也许我可以截屏主屏幕并添加半透明效果。在这种情况下,如何拍摄用户主屏幕的屏幕截图?
Apple拥有严格的隐私保护观点(我支持),因此我了解以上内容均不允许。
答案 0 :(得分:1)
import urllib.request
import bs4 as bs
source = urllib.request.urlopen('https://store.steampowered.com/search/?filter=weeklongdeals')
soup = bs.BeautifulSoup(source,'lxml')
searchResultContainer = soup.find('div',{'id':'search_result_container'})
containerHolder = searchResultContainer.findChildren()[1]
links = []
for a in containerHolder.findAll('a', href=True):
links.append(a['href'])
x = 0
description = []
for link in links:
source = urllib.request.urlopen(str(link))
soup = bs.BeautifulSoup(source,'lxml')
try:
test = soup.find('div',{'class':'game_description_snippet'}).get_text().strip()
description.append(soup.find('div',{'class':'game_description_snippet'}).get_text().strip())
except:
test = 'No description'
description.append('No description')
finally:
x += 1
print(f'{x}: {test}')
如果需要半透明效果,
let vc = ViewController()
vc.modalPresentationStyle = .overFullScreen
self.present(vc, animated: true, completion: nil)
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark)
blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.bounds
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(blurEffectView)
func takeScreenshot(view: UIView) -> UIImageView {
UIGraphicsBeginImageContext(view.frame.size)
view.layer.render(in: UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageWriteToSavedPhotosAlbum(image!, nil, nil, nil)
return UIImageView(image: image)
}