我需要在textview中找到不同范围的像素帧.我正在用- (CGRect)firstRectForRange:(UITextRange *)range;它来做.但是我无法找到如何实际创建一个UITextRange.
基本上这就是我要找的东西:
- (CGRect)frameOfTextRange:(NSRange)range inTextView:(UITextView *)textView {
UITextRange*range2 = [UITextRange rangeWithNSRange:range]; //DOES NOT EXIST
CGRect rect = [textView firstRectForRange:range2];
return rect;
}
Run Code Online (Sandbox Code Playgroud)
Apple表示必须进行子类化UITextRange并UITextPosition采用该UITextInput协议.我不这样做,但无论如何,我尝试了,遵循doc的示例代码并传递firstRectForRange导致崩溃的子类.
如果有更简单的方法UILables可以在textview 中添加不同的颜色,请告诉我.我尝试使用content editable设置为TRUE的UIWebView ,但我不喜欢与JS通信,并且着色是我唯一需要的东西.
提前致谢.
[self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:0]]
withRowAnimation:UITableViewRowAnimationNone];
Run Code Online (Sandbox Code Playgroud)
当我插入的那一行向下滑动每一行时.我希望他们立即跳到新的地方.我不想打电话reloadData从那以后我的所有细胞都会重新绘制.
是否可以删除此动画?
如何克隆repo(使用libgit2)
我想要做什么git clone用,但确实libgit2.我可能会问的是,究竟是什么git clone深入.
这就是我到目前为止所做的事情:
git_remotegit checkout以某种方式做.而现在我不知道该怎么做.我唯一的猜测是加载.idx到a git_index并使用git_repository_set_index,但是也没有显示任何文件.
编辑
我测试git checkout master了在半克隆的回购上运行,这就完成了工作.现在我只需要了解如何使用libgit2进行操作,似乎问题跟踪器中有一些有用的信息.
编辑2
我现在将添加我当前的代码,希望有一天有人能发现它有用,希望能成为我从未找到的快速启动代码.注:我使用的是Obj-C和Objective-Git这里的,但它主要是纯C.
+ (GTRepository *)cloneFromRemoteURL:(NSURL *)remoteURL toLocalURL:(NSURL *)localURL
{
// Let's suppose the URL looks like: https://github.com/libgit2/libgit2.git
// Then we need to get a URL like this too: git://github.com/libgit2/libgit2.git
// This may be a bit dodgy, but it will …Run Code Online (Sandbox Code Playgroud) 因此,对于iOS 6,UITextView可以使用一个referencedString,这对于语法高亮显示非常有用.
我正在做一些正则表达式模式,-textView:shouldChangeTextInRange:replacementText:我经常需要更改已经输入的单词的颜色.我认为没有其他选择,只能重置attributesText,这需要时间.
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
//A context will allow us to not call -attributedText on the textView, which is slow.
//Keep context up to date
[self.context replaceCharactersInRange:range withAttributedString:[[NSAttributedString alloc] initWithString:text attributes:self.textView.typingAttributes]];
// […]
self.textView.scrollEnabled = FALSE;
[self.context setAttributes:self.defaultStyle range:NSMakeRange(0, self.context.length)];
[self refresh]; //Runs regex-patterns in the context
textView.attributedText = self.context;
self.textView.selectedRange = NSMakeRange(range.location + text.length, 0);
self.textView.scrollEnabled = TRUE;
return FALSE;
}
Run Code Online (Sandbox Code Playgroud)
这在模拟器上运行得很好,但在iPad 3上每个都-setAttributedText需要几百毫秒.
我向Apple提交了一个错误,要求能够改变attributionText.它被标记为重复,所以我看不出他们对此有何看法.
更具体的问题:
如何在UITextView中更改某些范围的颜色,使用大量的彩色文本,并且每个都有足够的性能shouldReplaceText...? …
syntax-highlighting uitextview nsattributedstring uitextviewdelegate ios6
我想知道是否可能影响父div的bg颜色或不透明度.
我有一个透明白色的div:
background-color:rgba(255,255,255,0.9);
Run Code Online (Sandbox Code Playgroud)
div包含带圆角的文本字段,文本字段背景颜色在某种程度上可以是负透明度数字,因此div和textfield的总不透明度等于0.5?
它就像已经透明的div的圆形rec中的mmore透明度.
我提出了3种可能的解决方案:
你觉得我应该怎么做?
- 编辑---
我使用了解决方案#2的变体,我创建了一个png文件.这是(未经处理的)结果(点击联系我们打开模态div).很难看,因为模糊,但窗户也是透明的.
请注意,这远不是最佳解决方案,因为我更新下面的内容时必须更新png.
我UIBezierpath在UIView课堂上画了一个讲话泡泡.在视图类中包含UITextView.我使用以下代码来绘制语音气泡.
//BezierPathView.h
@interface BezierpathView : UIView<UITextViewDelegate>{
CGFloat animatedDistance;
UITextView *LXVolabel;
UIView *view;
UIBezierPath* speechBubbleTopPath;
UIBezierPath* rectanglePath;
UIBezierPath* speechBubbleBottomPath;
UIColor* darkGray;
UIColor* shadow;
CGSize shadowOffset;
CGFloat shadowBlurRadius;
NSString* textContent;
}
@property(nonatomic,strong)UIView *view;
@property(nonatomic,strong)UITextView *LXVolabel;
Run Code Online (Sandbox Code Playgroud)
//BezierPath.m
@implementation BezierpathView
@synthesize LXVolabel,view;
- (id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.LXVolabel = [[UITextView alloc]initWithFrame:CGRectMake(0, 0,self.frame.size.width , self.frame.size.height-10)];
self.LXVolabel.backgroundColor = [UIColor clearColor];
self.LXVolabel.delegate = self;
self.LXVolabel.font = [UIFont systemFontOfSize:20];
[self addSubview:self.LXVolabel];
CGRect applicationFrame = [[UIScreen mainScreen] …Run Code Online (Sandbox Code Playgroud) 这个问题是我上一个问题的演变或解决方案:克隆一个git repo(深入)我认为在这种情况下创建一个新问题是最好的事情,但我可能错了.
这个很简单:我将如何git checkout master使用libgit2做一些相同的事情
这似乎是一年前不可能的:https://github.com/libgit2/libgit2/issues/247
据此,至少5个月前克隆是可能的.但我从未见过有关如何操作的任何代码,文档或示例.(编辑)我的意思是我没有看到任何关于包含的完整克隆git checkout,也没有关于结帐的任何代码/文档.
正如标题所描述的那样,我希望为每个UIViewController和每个子类(如UITableViewController)添加自定义属性.我的第一个想法是创建一个类别,但后来我意识到不能在其中添加ivars,所以我无法合成属性.如果我只是子类UIViewController并在那里添加东西,它不会影响其他子类.
基本上我的目的是为我的'UINavigationController'子类添加一个自定义工具栏(不,我不能出于各种原因使用默认值).它需要询问每个viewController是否需要工具栏,以及 - 在这种情况下 - 是否为toolbarItems数组.这有点像我相信UIToolbar的工作原理吗?
你会怎么做?
objective-c ×4
uitextview ×3
c ×2
git ×2
ios6 ×2
categories ×1
contentsize ×1
css ×1
git-checkout ×1
git-clone ×1
html ×1
ios ×1
ios5 ×1
iphone ×1
libgit2 ×1
nsrange ×1
opacity ×1
subclassing ×1
transparency ×1
uibezierpath ×1
uitableview ×1