CGRect.offsetBy不工作

时间:2017-12-12 04:11:22

标签: ios swift view cgrect

如何重写下面的代码?

self.view.frame = CGRectOffset(self.view.frame, 0, movement)
  

'Offset'已被'offsetby'替换

当我用所谓的“解决方案”替换它时:

self.view.frame = CGRect.offsetby(self.view.frame, 0, movement)

我收到错误:

  

“实例成员'offsetBy'不能用于'CGRect'类型;你的意思是使用这种类型的值吗?”

1 个答案:

答案 0 :(得分:21)

您必须在CGRect的实例上调用self.view.frame = self.view.frame.offsetBy(dx: 0, dy: movement)

import sys, os
# */site-packages is where your current session is running its python out of
site_path = ''
for path in sys.path:
    if 'site-packages' in path.split('/')[-1]:
        print(path)
        site_path = path
# search to see if gensim in installed packages
if len(site_path) > 0:
    if not 'gensim' in os.listdir(site_path):
        print('package not found')
    else:
        print('gensim installed')