如何创建IBDesignable def FileCheck(self, filedirectory, fileextension, searchparameter):
total = 0
datetoday = time.strftime("%Y%m%d%I%M")
filename = "%s%s%s" % (filedirectory, datetoday, fileextension)
inputfile = open(filename)
for line in inputfile:
if re.search(searchparameter, line):
print('Search Match Found!')
if line != 1 and line != 0:
total += 1
print total
time.sleep(3)
以便我可以在界面构建器中调整文本的插入内容?我添加了可检查属性UITextView
,topInset
等,但现在我无法弄清楚如何实际更新bottomInset
的插入内容,以便更改反映在IB中
UITextView
答案 0 :(得分:1)
这就是你需要做的所有事情:
<?xml version="1.0"?>
<MPD
type="dynamic"
xmlns="urn:mpeg:dash:schema:mpd:2011"
availabilityStartTime="2017-04-27T11:22:32+08:00"
availabilityEndTime="2017-04-27T11:23:17+08:00"
minimumUpdatePeriod="PT5S"
minBufferTime="PT5S"
timeShiftBufferDepth="PT0H0M0.00S"
suggestedPresentationDelay="PT10S"
profiles="urn:hbbtv:dash:profile:isoff-live:2012,urn:mpeg:dash:profile:isoff
-live:2011"
xmlns:xsi="http://www.w3.org/2011/XMLSchema-instance"
xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd">
<Period start="PT0S" id="dash">
<AdaptationSet
id="1"
segmentAlignment="true"
maxWidth="1280"
maxHeight="720"
maxFrameRate="23">
<Representation
id="elemental_H264"
mimeType="video/mp4"
codecs="avc1.4d401f"
width="1280"
height="720"
frameRate="23"
sar="1:1"
startWithSAP="1"
bandwidth="5000000">
<SegmentTemplate
presentationTimeOffset="0"
timescale="1000"
media="elemental-$Time$.m4v"
initialization="elemental-init.m4v">
<SegmentTimeline>
<S t="3703228922" d="7508"/>
<S t="3703236430" d="7507"/>
<S t="3703243937" d="7508"/>
<S t="3703251445" d="7507"/>
<S t="3703258952" d="7508"/>
<S t="3703266460" d="7507"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
<AdaptationSet
id="2"
segmentAlignment="true">
<AudioChannelConfiguration
schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
value="1"/>
<Representation
id="elemental_AAC"
mimeType="audio/mp4"
codecs="mp4a.40.2"
audioSamplingRate="48000"
startWithSAP="1"
bandwidth="96000">
<SegmentTemplate
presentationTimeOffset="0"
timescale="1000"
media="elemental-$Time$.m4a"
initialization="elemental-init.m4a">
<SegmentTimeline>
<S t="3703228922" d="7508"/>
<S t="3703236430" d="7507"/>
<S t="3703243937" d="7508"/>
<S t="3703251445" d="7507"/>
<S t="3703258952" d="7508"/>
<S t="3703266460" d="7507"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
</Period>
</MPD>
如您所见,这些是我创建的import UIKit
@IBDesignable class TextViewWithInsets: UITextView {
@IBInspectable var topInset: CGFloat = 0 {
didSet {
self.contentInset = UIEdgeInsetsMake(topInset, self.contentInset.left, self.contentInset.bottom, self.contentInset.right)
}
}
@IBInspectable var bottmInset: CGFloat = 0 {
didSet {
self.contentInset = UIEdgeInsetsMake(self.contentInset.top, self.contentInset.left, bottmInset, self.contentInset.right)
}
}
@IBInspectable var leftInset: CGFloat = 0 {
didSet {
self.contentInset = UIEdgeInsetsMake(self.contentInset.top, leftInset, self.contentInset.bottom, self.contentInset.right)
}
}
@IBInspectable var rightInset: CGFloat = 0 {
didSet {
self.contentInset = UIEdgeInsetsMake(self.contentInset.top, self.contentInset.left, self.contentInset.bottom, rightInset)
}
}
}
TextViewWithInsets
子类的属性。您需要覆盖属性方法的UITextView
部分。然后,在Interface Builder中,这四个属性(Top Inset,Bottit Inset,Left Inset和Right Inset)将出现在Attributes Inspector中:attributes inspector in IB for new class
只需确保在Identity Inspector中将Storyboard中的TextView对象设置为didSet
或您选择的任何名称,如下所示:Set class of Text View object in storyboard to custom class
答案 1 :(得分:0)
快速5
如果要将其用于项目中的所有UITextView,请使用以下内容:
import UIKit
@IBDesignable extension UITextView {
@IBInspectable var topPadding: CGFloat {
get {
return contentInset.top
}
set {
self.contentInset = UIEdgeInsets(top: newValue,
left: self.contentInset.left,
bottom: self.contentInset.bottom,
right: self.contentInset.right)
}
}
@IBInspectable var bottomPadding: CGFloat {
get {
return contentInset.bottom
}
set {
self.contentInset = UIEdgeInsets(top: self.contentInset.top,
left: self.contentInset.left,
bottom: newValue,
right: self.contentInset.right)
}
}
@IBInspectable var leftPadding: CGFloat {
get {
return contentInset.left
}
set {
self.contentInset = UIEdgeInsets(top: self.contentInset.top,
left: newValue,
bottom: self.contentInset.bottom,
right: self.contentInset.right)
}
}
@IBInspectable var rightPadding: CGFloat {
get {
return contentInset.right
}
set {
self.contentInset = UIEdgeInsets(top: self.contentInset.top,
left: self.contentInset.left,
bottom: self.contentInset.bottom,
right: newValue)
}
}
}