레이블을 오른쪽 정렬로 조정하여 중앙 정렬 텍스트보기에 타임 스탬프를 추가하고 싶습니다.

Parth Patel p1nt0z

내 채팅 앱 중 하나에서 레이블과 텍스트보기를 사용했습니다. UITextView는 중앙 정렬이고 하나 이상의 레이블이 하위 뷰에 추가되고 잘 작동하는 텍스트에 따라 위치를 조정합니다.

하지만 내 필요는 whatsapp 응용 프로그램과 비슷하게 만드는 것입니다. 텍스트가 작고 라벨이 같은 줄 내에서 조정할 수있는 경우 거품이 두 줄로 확장되어 한 줄로 조정되지 않아야합니다.

요구 사항을 충족시킬 이미지를 첨부했습니다. whatsapp 앱과 유사한 timeStamp를 원함

미리 감사드립니다.

Parth Patel p1nt0z

Textkit- exclusionPaths의 도움으로 이것을 수행 할 수 있습니다.

    CGSize sizelbl = _lbl_Timestamp.frame.size;
[_lbl_Timestamp
 setFrame:CGRectMake(CGRectGetMaxX(_txtView.frame) - sizelbl.width - 5,
                     CGRectGetMaxY(_txtView.frame) - sizelbl.height - 5 - 3,
                     sizelbl.width, sizelbl.height)];


CGRect ovalFrame = [_txtView convertRect:_lbl_Timestamp.bounds fromView:_lbl_Timestamp];

// Since text container does not know about the inset, we must shift the frame to container coordinates
ovalFrame.origin.x -= _txtView.textContainerInset.left;
ovalFrame.origin.y -= _txtView.textContainerInset.top;

// Simply set the exclusion path
UIBezierPath *ovalPath = [UIBezierPath bezierPathWithOvalInRect: ovalFrame];
_txtView.textContainer.exclusionPaths = @[ovalPath];

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관