美文网首页iOS
获取cell相对viewcontroller坐标

获取cell相对viewcontroller坐标

作者: 说不出口的喵 | 来源:发表于2018-08-03 16:09 被阅读82次

    -(UICollectionViewCell*)collectionView:(UICollectionView*)collectionView cellForItemAtIndexPath:(NSIndexPath*)indexPath{

        FH_HomeButtonCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:FH_HomeButtonCellID forIndexPath:indexPath];

        cell.fh_QZIconModel=_dataArr[indexPath.item];

        if(indexPath.item==2) {

            CGRectcellRect = [collectionViewconvertRect:cell.frametoView:collectionView];

            //cell在当前屏幕的位置

            UIWindow * window=[[[UIApplication sharedApplication] delegate] window];

            CGRectrect2 = [_collectionViewconvertRect:cellRecttoView:window];

            NSNumber *obj1 = [NSNumber numberWithFloat:rect2.origin.x];

            NSNumber *obj2 = [NSNumber numberWithFloat:rect2.origin.y];

            NSNotification * notice = [NSNotification notificationWithName:@"userguide" object:nil userInfo:@{@"Rect1":obj1,@"Rect2":obj2}];

            [[NSNotificationCenter defaultCenter]postNotification:notice];

            NSLog(@"--------22222222------- %f - %f # %f - %f",rect2.origin.x,rect2.origin.y,rect2.size.width,rect2.size.height);

        }

        returncell;

    }

    相关文章

      网友评论

        本文标题:获取cell相对viewcontroller坐标

        本文链接:https://www.haomeiwen.com/subject/xefuvftx.html