2
나는 빠른 3에 다음 OBJ-C 코드로 변환하려고
원하는 변환 :스위프트 3 NSClassFromString가 ","구분자
UIView *targetView = nil;
for (UIView *subView in self.navigationController.navigationBar.subviews) {
if ([subView isKindOfClass:NSClassFromString(@"UINavigationButton")]) {
for (UILabel *label in subView.subviews) {
if ([label isKindOfClass:[UILabel class]]) {
if ([label.text isEqualToString:"right"]) {
targetView = subView;
break;
}
}
}
}
}
CGRect rect = [targetView convertRect:targetView.frame toView:self.view];
CGPoint center_you_need = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
지금까지 내가 가진이 :
var targetView: UIView? = nil
for subView: UIView in self.navigationController!.navigationBar.subviews {
if (subView is NSClassFromString("UINavigationButton")) {
for label: UILabel in subView.subviews {
if (label is UILabel) {
if (label.text! == "right") {
targetView = subView
}
}
}
}
}
var rect = targetView!.convertRect(targetView!.frame, to: self.view)
var center_you_need = CGPoint(x: rect.midX, y: rect.midY)
UIBarButtonItem의 중앙 위치를 가져 오는 다른 방법이 있습니까? – user2722667
업데이트 된 답변을 살펴보십시오. 지금 작동하는지 확실하지 않지만 다음과 같이해야합니다. :) – alexburtnik